标签:
UI源码:
<h4>First instance, without parameters</h4> <div data-bind=‘component: "message-editor"‘></div> <h4>Second instance, passing parameters</h4> <div data-bind=‘component: { name: "message-editor", params: { initialText: "Hello, world!" } }‘></div>
视图模型源码:
ko.components.register(‘message-editor‘, { viewModel: function(params) { this.text = ko.observable(params && params.initialText || ‘‘); }, template: ‘Message: <input data-bind="value: text" /> ‘ + ‘(length: <span data-bind="text: text().length"></span>)‘ }); ko.applyBindings();
下午继续更
KnockoutJS 3.X API 第四章 数据绑定(5) 控制流component绑定
标签:
原文地址:http://www.cnblogs.com/smallprogram/p/5933545.html