1. 程式人生 > >微信小程式通過按鈕傳值和取值問題

微信小程式通過按鈕傳值和取值問題

在wxml檔案中進行傳值:

<button class='cancle_btn' type='default' size='mini' bindtap='cancleCollected' id="{{item.poem_id}}">取消收藏</button>

在js檔案中進行取值:

cancleCollected: function(e) {

     console.log("點選了取消收藏")

     console.log("poem_id=" + e.currentTarget.id)

},

結果:

點選了取消收藏 collections.js? [sm]:82 poem_id=70080