knockoutJS+knockout.multimodels使用記錄

能夠屢次綁定,但不能嵌套綁定javascript

錯誤示例html

<div class="con_c" data-model="viewModel">

  <div data-moel="lstViewModel">

  </div>

</div>

<script type="text/javascript">

var vm = new ViewModel();

var vm2 = new CreateModel();


ko.attach("viewModel", vm);

ko.attach("lstViewModel", vm2);

</script>

 

會報錯:java

 

可是,若是是並列表使用,就不會:spa

<div class="con_c" data-model="viewModel">
  
</div>

<div data-moel="lstViewModel">
</div>

<script type="text/javascript">

var vm = new ViewModel();

var vm2 = new CreateModel();


ko.attach("viewModel", vm);

ko.attach("lstViewModel", vm2);

</script>
相關文章
相關標籤/搜索