3
回答
seajs中怎么去实现 <a href='javascript:xxx()'></a>
【腾讯云】校园拼团福利,1核2G服务器10元/月!>>>   

seajs 刚学习,请指教~

举报
leon_rock
发帖于4年前 3回/735阅
共有3个答案 最后回答: 4年前
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
顶部