小程序按钮触发转发页面
1、需求:要求点击列表某条信息然后把该条信息的某个参数分享出去
2、思路:为了方便直接把button当做view,去掉button的样式,绑定data-item,直接触发onShareAppMessage就可以获取参数跳页面
3、实现:
wxml
<button open-type="share" class="noBtn" slot='list' wx:for="{{list}}" wx:key="*this" data-item="{{item}}"> ... </button>
wxss
.noBtn{ color: #FFFFFF; font-size: 28rpx; font-weight: bold; background-color: transparent !important; padding: 0; margin: 0; border: none; line-height: normal; border-color: transparent !important; } .noBtn::after{ border:none; }
js
onShareAppMessage: function (e) { return { title: '访客申请', path: `/pages/user/cusApply/cusApply?applyType=2&perid=`+e.target.dataset.item.perId } } })
4、效果