1. 程式人生 > 其它 >微信小程式給button加連結

微信小程式給button加連結

技術標籤:javascript小程式

微信小程式給button加連結

微信小程式button裡面無法新增onclick事件,需要在js裡面寫。
WXML程式碼:<button type="idcard" value="{{order_amount}}" class="carBtn" data-refund_id="{{refund_id}}" id="{{refund_id}}" bindtap="goTodocommunicate_history"> ></button>

JS程式碼:

goTodocommunicate_history :function(e){
    var refund_id = e.currentTarget.dataset.refund_id
    console.log(refund_id)
    wx.navigateTo({
      url: '../refund/communicate_history?refund_id='+ refund_id,
    });
  },

按鈕變透明的css樣式

.carBtn{
    background-color:transparent;    
}

效果圖片: 在這裡插入圖片描述