如何使用CanJS进行双向绑定?
Enter the Text : <input type="text" name="name" can-value="enteredText" />
Display the Text: {{enteredText}}可以显示多个方法?使用ViewModel?
发布于 2017-06-03 03:22:56
can-value是v2中的旧方法。在Canjs 4.0中,你可以像这样做双向绑定:
Enter the Text : <input type="text" name="name" value:bind="enteredText" />
Display the Text: {{enteredText}}请参阅:https://canjs.com/doc/can-stache-bindings.twoWay.html
下面是一个演示语法的jsbin:
http://jsbin.com/vogavevico/edit?html,js,console,output
发布于 2017-04-12 15:20:37
请看这里(docu for v2和for v3)。
至少如果你使用(现在推荐的)组件方法,你可以写
<my-component {(some-prop)}="value"/><!-- v2 -->
<!-- syntax for v3 remains: {(prop)}="key" for two-way binding. -->这是文档中的内容。
https://stackoverflow.com/questions/43351083
复制相似问题