Last active
December 25, 2015 11:59
-
-
Save xiaojue/6972903 to your computer and use it in GitHub Desktop.
bad amd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define("someapp.js",["a","b","c","d","e","f","g","h","i","j","k"],function(a,b,c,d,e,f,g,h,i,j,k){ | |
}); | |
//what the fuck? 这书写维护起来。。简直了。 | |
//a.js | |
define("a",[],function(){ | |
var a = document.getElementById("a"); | |
return a; | |
}); | |
define("someapp.js",["a"],function(require,exprots,module){ | |
var div = document.createElement("div"); | |
div.id = "a"; | |
document.body.appendChild(div); | |
var a = require("a"); | |
console.log(a) //null; | |
//这啥玩意啊。。完全不符合预期和逻辑啊? | |
//其实这就是amd的本质,先加载,然后运行,然后保存结果,然后等着被你调用。 | |
//cmd 则是,加载完毕保存代码,调用运行时再解析结果,返回。 | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment