- data里声明变量
data: {
Roleid: ''
},
- 赋值setData,这里直接从缓存中拿
onLoad: function (options) {
this.setData({
Roleid: wx.getStorageSync('userinfo').role.role_id
})
},
- 页面上设置
<view class="col-5 work_cart" bindtap="OpenCheck" data-Roleid="{{Roleid}}">
<image src="/icons/icon11.png" mode="aspectFit"></image>
<view>区域检查</view>
</view>
- 取值判断把id传到跳转的页面中
OpenCheck(e) {
const roleid = e.currentTarget.dataset.roleid;
if(roleid == 2){
wx.navigateTo({
url: '/pages/check_manager/index?role_id=' + wx.getStorageSync('userinfo').role.role_id,
})
}else{
wx.navigateTo({
url: '/pages/check/index?role_id=' + wx.getStorageSync('userinfo').role.role_id,
})
}
},