国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 熱點 > 微信 > 正文

微信小程序 bindtap 傳參的實例代碼

2024-07-22 01:19:23
字體:
來源:轉載
供稿:網友

微信小程序 bindtap 傳參 ,代碼如下所示:

//index.wxml<view bindtap="changeIndex" data-src="我固定參數"></view>//index.jspage({ data:{ }, changeIndex(e){ console.log(e.currentTarget.dataset.src); //我是固定參數 }});

可以看出 參數是通過給標簽設置 data-參數名=“參數值” 自定義屬性的方式 來傳遞的 例如想傳遞兩個參數

//index.wxml<view bindtap="changeIndex" data-src1="我固定參數1" data-src2="我是固定參數2" > </view>//index.jspage({ data:{  }, changeIndex(e){ console.log(e.currentTarget.dataset.src1); //我是固定參數1 console.log(e.currentTarget.dataset.src2); //我是固定參數2 }});

如果需要傳遞動態的參數 例如遍歷渲染時 想傳遞 index 給 changeIndex方法

//index.wxml<view wx:for="{{lists}}" wx:for-index="index" wx:key="index" data-index="{{index}}" >{{item.title}}</view>//index.jspage({ data:{ lists:[{title:'參數1',id:1},{title:'參數2',id:2}] }, changeIndex(e){ console.log(e.currentTarget.dataset.index); }})

知識點補充:

微信小程序:bindtap方法傳參

1、wxml

<view bindtap="pay_again" data-name="{{orderList.jid}}" data-fee="{{orderList.act_fee}}" data-mobile="{{orderList.p_phone}}" data-act="{{orderList.act_name}}" class="operating f_r webkit-box" style="line-height:30px;">    <a href="" class=" rel="external nofollow" pay bg_red">繼續支付</a>   </view>

2、js

// 再次發起支付請求,調用后臺PHP pay_again:function(e){ var that = this; that.setData({  jid: e.currentTarget.dataset.name,  act_name: e.currentTarget.dataset.act,  act_fee: e.currentTarget.dataset.fee,  mobile: e.currentTarget.dataset.mobile }) console.log('活動訂單id = ' + that.data.mobile); }

總結

到此這篇關于微信小程序 bindtap 傳參的實例代碼的文章就介紹到這了,更多相關微信小程序 bindtap 傳參內容請搜素錯新站長站以前的文章或下面相關文章,希望大家以后多多支持錯新站長站!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 凌海市| 汉阴县| 祁连县| 岳普湖县| 青浦区| 鄂托克前旗| 黑河市| 金昌市| 鲁甸县| 繁峙县| 新河县| 昌吉市| 湄潭县| 镇雄县| 天等县| 清水县| 德惠市| 西安市| 汉源县| 威海市| 和政县| 紫阳县| 儋州市| 安达市| 长子县| 华安县| 曲沃县| 密山市| 迁西县| 平顶山市| 综艺| 亳州市| 东光县| 大城县| 湘潭市| 浙江省| 抚远县| 南城县| 图木舒克市| 馆陶县| 汉阴县|