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