當我使用敲除組件時,出現綁定錯誤。 HTML:Uncaught ReferenceError:無法處理綁定「text:function(){return username}」
<html >
<head>
<link rel="stylesheet" href="css/default.css">
</head>
<body>
<main id="shell">
<!-- logo & top level links -->
<header>
<header-widget></header-widget>
</header>
</main>
<script type="text/javascript" src="thirdparty/requirejs/require-2.3.3.js" data-main='./js/requirejs.config'></script>
</body>
Java腳本:
var requireConfig = {
baseUrl: './',
paths: {
jquery: 'thirdparty/jquery/jquery-1.11.2',
ko: 'thirdparty/knockout/knockout-3.4.2',
text: 'thirdparty/requirejs/text'
},
shim: {
}
};
require.config(requireConfig);
define(
function(require) {
require(['jquery', 'ko'], function($, ko) {
var modle = {
};
$(document).ready(function() {
ko.components.register('header-widget', {
viewmodel: function(params){
this.username = ko.observable('tom');
},
template: '<div data-bind="text:username">userxxx</div>'
});
ko.applyBindings(modle);
});
});
}
);
我覈對姓名,他們是正確的。我無法弄清楚爲什麼綁定失敗。我檢查了stackoverflow.com,但無法找到與此相同的問題。你可以幫我嗎?