我越来越:KO未定义
Uncaught TypeError: Cannot call method 'applyBindings' of undefined
我看着在Chrome网络选项卡,我看到knockout.js被加载。 我可以在控制台标签上输入window.ko
,并看到淘汰赛的代码
那么,为什么错误?
config.js:
var require = {
baseUrl: "/scripts"
};
main.js:
require([
"lib/knockout"
],
function (ko) {
ko.applyBindings();
});
的index.html:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="scripts/config.js"></script>
<script data-main="app/main.js" src="scripts/lib/require.js"></script>
</head>
<body>
<input type="text" data-bind="value: test" />
</body>
</html>
敲除的AMD/RequireJS支持依赖于条件['如果(typeof运算定义=== '功能' &&限定[ 'AMD'])'](https://github.com/SteveSanderson/knockout /blob/master/build/fragments/amd-pre.js)。如果以前的CommonJS运行时测试没有通过,它将默认定义全局'window.ko'。 – 2013-03-09 23:25:46