使用WinJS绑定多个HTML属性? [英] Binding multiple HTML properties using WinJS?
问题描述
WinJS允许您在运行时动态绑定HTML属性,类似于XAML绑定.
WinJS allows you to bind HTML properties dynamically at run-time, similar to XAML binding.
<div id="itemTemplate" data-win-control="WinJS.Binding.Template"...>
<h3 data-win-bind="innerText: timestamp"></h3>
</div>
如果我还想同时绑定<h3>
的字体颜色样式,如何实现?
How if I want to also bind the font color style for <h3>
as well, how do I achieve that?
推荐答案
与使用{key:value,key2:value2}
语法的data-win-options
绑定不同. data-win-binding
使用类似于inline-css样式的语法.
Unlike the data-win-options
binding which makes use of {key:value,key2:value2}
syntax. data-win-binding
uses a syntax similar to inline-css styles.
使用property:bindingValue;property2:bindingValue2
等将允许您将多个属性绑定到同一个HTML控件.
Using property:bindingValue;property2:bindingValue2
etc will allow you bind multiple properties to the same HTML control.
作为回答上述问题的示例:
As an example to answer the question above:
<div id="itemTemplate" data-win-control="WinJS.Binding.Template"...>
<h3 data-win-bind="style.color: fontcolor; innerText: timestamp"></h3>
</div>
这篇关于使用WinJS绑定多个HTML属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!