聚合物中的双括号[[]]与双括号{{}} [英] Double Brackets [[ ]] vs Double Braces {{ }} in Polymer
问题描述
解释聚合物1.0中双括号([[...]]
)和双括号({{...}}
)之间的区别的简洁方式是什么?
例如,在 <iron-list>
元素的文档中HTML显示:
<template is="dom-bind">
<iron-ajax url="data.json" last-response="{{data}}" auto></iron-ajax>
<iron-list items="[[data]]" as="item">
<template>
<div>
Name: <span>[[item.name]]</span>
</div>
</template>
</iron-list>
</template>
为什么data
在一个点(last-response="{{data}}"
)中用双花括号包围,而在另一个位置又用双括号(items="[[data]]"
)包围?
绑定可以是单向(使用[[]])或双向(使用{{}},也可以使用notify).>
解释*方式绑定思考流量.单向绑定是在更新模型时,视图也会更新.反之亦然,则是双向绑定.
有关更多信息,请参见文档.
>What's a succinct way to explain the difference between double brackets ([[...]]
) and double braces ({{...}}
) in Polymer 1.0?
For instance, in the documentation for the <iron-list>
element the sample HTML shows:
<template is="dom-bind">
<iron-ajax url="data.json" last-response="{{data}}" auto></iron-ajax>
<iron-list items="[[data]]" as="item">
<template>
<div>
Name: <span>[[item.name]]</span>
</div>
</template>
</iron-list>
</template>
Why is data
bounded by double braces in one spot (last-response="{{data}}"
) but bounded by double brackets (items="[[data]]"
) in another spot?
Binding can be either one-way (using [[]]) or two-way (using {{}}, but also use notify).
To explain *-way binding think traffic. one-way binding is when you update model, the view gets updated. When the vice-versa is also true it is a two-way binding.
For more information see the documentation.
这篇关于聚合物中的双括号[[]]与双括号{{}}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!