简体   繁体   English

对“数据链接元素”的困惑

[英]Confusion on “Data-linked elements”

I am reading up this page http://www.jsviews.com/#linked-elem-syntax and testing a bit. 我正在阅读此页面http://www.jsviews.com/#linked-elem-syntax并进行了一些测试。

  1. I like to start with this .. 我喜欢从这个开始。

Notice that the <input data-link="name trigger=true"/> tag automatically has two-way data-binding. 请注意, <input data-link="name trigger=true"/>标记自动具有双向数据绑定。

Am I correct to say that if removing "trigger=true" will make the one-way binding? 我是否正确地说,如果删除“ trigger = true”将进行单向绑定? Or, Is it still two-way binding? 还是仍然是双向绑定?

The only difference that I found for having "trigger=true" and not having "trigger=true" is that you will get the update on property-changed event if you have "trigger=true". 我发现具有“ trigger = true”而不具有“ trigger = true”的唯一区别是,如果您具有“ trigger = true”,则将获得属性更改事件的更新。 otherwise, you will see get the update on lost-focus event. 否则,您将看到有关失焦事件的更新。

  1. I am also confused about having ":" before at the end. 我也对结尾之前使用“:”感到困惑。

Notice the full syntax for the has an additional ':' before the '}' at the end. 请注意,的完整语法在末尾的“}”前还有一个附加的“:”。 It corresponds to the two-way data binding. 它对应于双向数据绑定。

Does it mean that having ":" at the end has the same effect as having "trigger=true"? 这是否意味着末尾带有“:”与具有“ trigger = true”具有相同的效果?

But i tried the code below and it doesn't work like the code that has "trigger=true". 但是我尝试了下面的代码,它不像具有“ trigger = true”的代码那样工作。

<input data-link="{:name:}"/>

The section Optional two-way data-binding of http://www.jsviews.com/#linked-elem-syntax explains that the ":" at the end determines whether you have two-way binding or not. http://www.jsviews.com/#linked-elem-syntax的“ 可选双向数据绑定”部分说明,最后的“:”确定是否具有双向绑定。

If you do have two-way binding then you can also set trigger=true to trigger a binding update after every character entry (after key down). 如果您确实有双向绑定,则还可以将trigger=true设置为在每次输入字符后(按下键后)触发绑定更新。 Otherwise, by default, the update is on "blur" or "change" only. 否则,默认情况下,更新仅在“模糊”或“更改”上进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM