1,需要同一个主体
2,特定场景值才可以显示
使用组件跳转
<view style="z-index: 11;position: absolute;" hidden="{{ officialAccount }}">
<official-account bindload='bindload' binderror="binderror"></official-account>
</view>
officialAccount: true, //公众号关注组件显示
this.data.officialAccount = false; // 显示跳转公众号组件
this.setData({'officialAccount': false});
binderror (e) {
console.log(‘组件加载失败’, e)
wx.showToast({
title: ‘组件加载失败!’+e.detail.errMsg+ e.detail.scene,
icon: ‘none’,
duration: 2500
})
},
bindload(){
wx.showToast({
title: ‘组件加载成功呢的’,
icon: ‘none’,
duration: 2500
})
},
官方文档地址
https://developers.weixin.qq.com/miniprogram/dev/component/official-account.html