微信小程序の条件渲染

<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)
  }

})

 

posted @ 2019-11-26 16:01  卖雨伞的小男孩  阅读(153)  评论(0编辑  收藏  举报