JSFiddle - React, Tailwind, and code Playground
by leez20120909
HTML
<p> 姓氏: <strong data-bind="text:firstName"></strong></p>
<p>名字e: <strong data-bind="text:lastName"></strong></p>
<p>全名: <strong data-bind="text:fullName"></strong></p>
<p>姓氏:<input type="text" data-bind="value:firstName"></p>
JavaScript
function AppViewModel() {
var self=this;
self.firstName = ko.observable("张");
self.lastName = ko.observable("三");
self.fullName = ko.computed(function() {
return self.firstName() + " " + self.lastName();
}, self);
}
ko.applyBindings(new AppViewModel);