3
回答
seajs中怎么去实现 <a href='javascript:xxx()'></a>

seajs 刚学习,请指教~

举报
leon_rock
发帖于5年前 3回/828阅
共有3个答案 最后回答: 5年前
in app.js
define('app', [], function(require, exports, module){
    var sayHello = function() {
        alert('hello');
    };
    //u can expose the sayHello func here or not
    exports.sayHello = sayHello;
});

//in use
seajs.use('app', function(app){
   //just expose the method in here
    window.sayHello = app.sayHello;    
});

//so, u can do like your code
<a href='javascript:sayHello();'>say hello</a>

this is my solution. I'm also new to seajs.We can discuss.

引用来自“多萨穆大叔”的答案

in app.js
define('app', [], function(require, exports, module){
    var sayHello = function() {
        alert('hello');
    };
    //u can expose the sayHello func here or not
    exports.sayHello = sayHello;
});

//in use
seajs.use('app', function(app){
   //just expose the method in here
    window.sayHello = app.sayHello;    
});

//so, u can do like your code
<a href='javascript:sayHello();'>say hello</a>

this is my solution. I'm also new to seajs.We can discuss.
It works
顶部