3
回答
seajs中怎么去实现 <a href='javascript:xxx()'></a>
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

seajs 刚学习,请指教~

举报
小鲅鱼
发帖于4年前 3回/706阅
共有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
顶部