漫漫长路 2013-11-15
代码如下:
Today's message is: <span data-bind="text: myMessage"></span> <script type="text/javascript" src="~/Scripts/knockout-2.3.0.debug.js"></script> <script type="text/javascript"> var viewModel = { myMessage: ko.observable() }; viewModel.myMessage("Hello, world!"); ko.applyBindings(viewModel); </script>
代码如下:
price: ko.observable(24.95) viewModel.priceRating = ko.dependentObservable( function () { return this.price() > 50 ? "expensive" : "affordable"; }, viewModel);
代码如下:
The item is <span data-bind="text: priceRating"></span> today.
代码如下:
viewModel.myMessage("<i>Hello, world!</i>");
var text = "";if (!node) return "";if (!text = node.textContent;if (node.childNodes[0] && node.child