You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
2.2 KiB
58 lines
2.2 KiB
<!--pages/test/index.wxml-->
|
|
<text>pages/test/index.wxml</text>
|
|
<text>----------------变量及循环-------------------<br /></text>
|
|
<text>{{msg}}</text>
|
|
<view wx:for="{{list}}">{{item}}</view>
|
|
<view wx:for="{{[10,11,12,13]}}">{{item}}</view>
|
|
<view wx:for="{{list_data}}" wx:for-index="key" wx:for-item="v">
|
|
{{key}}-{{v.name}}
|
|
</view>
|
|
|
|
<block wx:for="{{[1, 2, 3]}}">
|
|
<view> {{index}}: </view>
|
|
<view> {{item}} </view>
|
|
</block>
|
|
<text>----------------wx:key-------------------<br /></text>
|
|
<switch wx:for="{{objectArray}}" wx:key="unique" style="display: block;"> {{item.id}} - {{item.unique}}</switch>
|
|
<button bindtap="switch"> Switch </button>
|
|
<button bindtap="addToFront">追加元素</button>
|
|
<switch wx:for="{{numberArray}}" wx:key="*this" style="display: block;"> {{item}} </switch>
|
|
<button bindtap="addNumberToFront"> Add to the front </button>
|
|
|
|
<text>----------------wx:dataset/mark区别-------------------<br /></text>
|
|
<button data-name="测试" data-name-key="这里会合并并置换为大写" data-nameValue="这里为置换为小写" bindtap="getname">获取名称</button>
|
|
|
|
<view mark:myMark="last" bindtap="bindViewTap">
|
|
<button mark:anotherMark="leaf" bindtap="bindButtonTap">按钮</button>
|
|
</view>
|
|
|
|
<view>mark 和 dataset 很相似,主要区别在于: mark 会包含从触发事件的节点到根节点上所有的 mark: 属性值;而 dataset 仅包含一个节点的 data- 属性值。
|
|
|
|
细节注意事项:
|
|
|
|
如果存在同名的 mark ,父节点的 mark 会被子节点覆盖。
|
|
在自定义组件中接收事件时, mark 不包含自定义组件外的节点的 mark 。
|
|
不同于 dataset ,节点的 mark 不会做连字符和大小写转换。</view>
|
|
|
|
<text>----------------模板渲染-------------------<br /></text>
|
|
|
|
<template name="staffName">
|
|
<view>
|
|
FirstName: {{firstName}}, LastName: {{lastName}},e:{{e}}
|
|
</view>
|
|
</template>
|
|
<template is="staffName" data="{{...staffA}}"></template>
|
|
<template is="staffName" data="{{...staffB}}"></template>
|
|
<template is="staffName" data="{{...staffC}}"></template>
|
|
|
|
|
|
<template is="staffName" data="{{...staffA,e:5}}"></template>
|
|
|
|
|
|
<template name="test">
|
|
<view>
|
|
名称:{{name}}
|
|
</view>
|
|
</template>
|
|
<template is="test" data="{{name:a,bar:b}}"></template>
|
|
|
|
|