微信小程序 bindtap 传参 ,代码如下所示:

//index.wxml
<view bindtap="changeIndex" data-src="/UploadFiles/2021-04-02/我固定参数">

可以看出 参数是通过给标签设置 data-参数名=“参数值” 自定义属性的方式 来传递的 例如想传递两个参数

//index.wxml
<view bindtap="changeIndex" data-src1="我固定参数1" data-src2="我是固定参数2" >
 
</view>
//index.js
page({
 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.js
page({
 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);
 }

总结

华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。

更新日志