标签:pre data item math dex imp select htm sele
helloworld.wxml
<view> <block wx:for="{{items}}" wx:for-item="item" wx:key="index"> <view>{{index}}{{item.name}}</view> </block> </view>
<view wx:if="{{select==1}}"> 1 </view> <view wx:elif="{{select==2}}"> 2 </view> <view wx:else> 3 </view> <template name="templateItem"> <view>helloworld</view> </template>
helloworld.js
Page({ /** * 页面的初始数据 */ data: { items:[ {name:"A"}, { name: "B" }, { name: "C" }, { name: "D" }, { name: "E" } ], select: Math.floor(Math.random()*3+1) } })
import 只能引用模板
include 除模板和block都引入
标签:pre data item math dex imp select htm sele
原文地址:https://www.cnblogs.com/7fancier/p/9410797.html