微信小程序の条件渲染
<view> 今天吃什么 </view> <view wx:if="{{condition==1}}">饺子</view> <view wx:elif="{{condition==2}}">面条</view> <view wx:else>米饭</view>
Page({
data: {
message: "hello world",
products: [{
name: "商品A"
},
{
name: "商品B"
},
{
name: "商品C"
},
{
name: "商品D"
},
{
name: "商品E"
}
],
condition: Math.floor(Math.random() * 3 + 1)
}
})