//1.创建一个ViewModel var myViewModel = { personName:aehyok, personAge:25 };2.为View"/>

Knockout.Js创建一个ViewModel

Knockout.Js创建一个ViewModel
Knockout.Js创建一个ViewModel
 
<script type="text/javascript">
    //1.创建一个ViewModel
    var myViewModel = {
        personName:'aehyok',
        personAge:25
    };
</script> 
 
2.为ViewModel创建一个声明式绑定的简单的View
 
The name is <span data-bind="text:personName"></span>
 
3.激活Knockout
ko.applyBindings(myViewModel);
 
4.查看运行效果

推荐阅读