标签:blog ar 使用 java on div log bs as
从何而来
本系列摘抄自knockoutjs官方文档,同时结合自身项目使用记录心得。
目标
knockoutjs实现CSS显示的绑定
例子
<div data-bind="visible: shouldShowMessage"> You will see this message only when "shouldShowMessage" holds a true value. </div> <script type="text/javascript"> var viewModel = { shouldShowMessage: ko.observable(true) // Message initially visible }; viewModel.shouldShowMessage(false); // ... now it‘s hidden viewModel.shouldShowMessage(true); // ... now it‘s visible again </script>
通过方法或表达式实现
<div data-bind="visible: myValues().length > 0"> You will see this message only when ‘myValues‘ has at least one member. </div> <script type="text/javascript"> var viewModel = { myValues: ko.observableArray([]) // Initially empty, so message hidden }; viewModel.myValues.push("some value"); // Now visible </script>
标签:blog ar 使用 java on div log bs as
原文地址:http://www.cnblogs.com/xiguain/p/4122178.html