Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.0k views
in Technique[技术] by (71.8m points)

使用vue的情况下 如何维护多个按钮 如下面代码

在实际开发中可能按钮文字 color type 都是动态的 如果不用jsx如何维护呢我希望是用一个数组 来维护渲染通过订单状态来显隐之类的
<van-button v-if="orderStatus===5 || orderStatus===4" plain round type="info">删除订单</van-button>
<van-button v-if="orderStatus===3 && deliveryType===2" plain round type="info">确认收货</van-button>
<van-button v-if="orderStatus===3 && deliveryType===1" plain round type="info">提货二维码</van-button>
<van-button v-if="orderStatus===4 || orderStatus===3 && deliveryType===2" plain round type="info">查看物流</van-button>
<van-button v-if="orderStatus===1" plain round type="info">取消订单</van-button>
<van-button v-if="orderStatus===1" plain round type="info">付款</van-button>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
computed: {
  btnList () {
    const list = []
    if (orderStatus == 1) {
        list.push('付款', '取消订单')
    }
    return list
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...