到目前为止,我曾经在Handlebars.registerHelper and templates
文件本身内写了html
。现在我正在尝试将require.js
实现到我的应用程序中。我将helper functions
移到了.js
文件中,并将templates
文件保存在html
文件中。我按以下方式配置require
。
requirejs.config({
baseUrl: "lib/js",
paths: {
js: "../../js",
handlebars:"handlebars-v1.1.2"
},
shim:{
"handlebars":{
deps:[],
exports:"Handlebars"
},
}
}
requirejs(["js/desktopHelper.js"])
desktopHelper.js:
define(
["handlebars"],
function(Handlebars){
Handlebars.registerHelper("maxmizeFun", function(json,attributeName){return json[attributeName];});
}
);
使用此配置在浏览器中打开我的应用后,我无法打开console(F12)
而无法关闭browser
也完全挂起我的应用。
注意:为了进行测试,在我在浏览器中打开应用程序之前,我打开console
并打开应用程序,我观察desktopHelper.js
已加载但文件中没有代码。我不知道它是怎么发生的。
我做错了。
任何人都可以帮助我。