with绑定用来创建一个绑定上下文,在子元素内的所有绑定都在这个上下文中进行。
示例代码:
//.W片段
<h1 bind-text="city"> </h1>
<p bind-with="coords">
Latitude: <span bind-text="latitude"> </span>,
Longitude: <span bind-text="longitude"> </span>
</p>
//.js片段
city="London",
coords= {
latitude: 51.5001524,
longitude: -0.1262362
}
在上面的代码中,我们为段落p标签指定了数据上下文coords,在它的子元素中,我们就可以直接绑定coords的属性latitude和longitude了。
另外,with绑定也可以使用虚拟标签:
<ul>
<li>Header element</li>
<!-- justep.Bind with: outboundFlight -->
...
<!-- /justep.Bind-->
<!--justep.Bind with: inboundFlight -->
...
<!-- /justep.Bind-->
</ul>
本文由WeX5君整理,WeX5一款开源免费的html5开发工具,H5 App开发就用WeX5!
阅读其他app 开发相关文章:http://doc.wex5.com/?p=3443
评一波