在下面的代码中,我正在调用myscript.getNum();
但myscript.js
抛出一个错误说
意外的标记 (
jloader.js
require(["evtManager","myscript"] , function(evtManager , myscript) {
var el = document.getElementById("Clickarea");
evtManager.addEvent(el , "click" , function(){
myscript.getNum();
});
});
myscript.js -> 加载myscript2.js
并调用一个函数getValue()
define(["myscript2"], function(myscript2)
{
getNum : function(){ //Throws an error "Unexpected token ("
var x = require("myscript2").getValue();
return 5 + x;
}
});
myscript2.js
define({
getValue : function(){
return 30;
}
})