angular h5跳转小程序,wx-open-launch-weapp开放标签不显示,点击无反应?
用的Angular 写的SPA 页面, 扫瞄分享功能都可以成功, 服务号是认证过的,sdk用的npm 包方式引入, 名为weixin-js-sdk, 查了版本是1.6.0,其他微信版本,iOS版本都是符合的,但是wx-open-launch-weapp 按钮不显示,点击无反应,打开看Vconsole工具查看element元素,元素是在的,就是不显示,在线跪求大佬指点。贴上代码 ngOnInit() {
this.initPage();
// init wxInit code
const url = encodeURIComponent(window.location.href);
this.wxsdk.getJSAPI(url, 'offical').subscribe(res => {
this.wxsdk.initConfig(['scanQRCode'], res, ['wx-open-launch-weapp']);
});
}
ngAfterViewInit(): void {
setTimeout(()=>{
this.appTaginit();
},1000)
}
appTaginit(){
const wxOpenApp = document.getElementById('wxOpenInAPP') as Element;
wxOpenApp.innerHTML = '<wx-open-launch-weapp id="launch-btn" username="gh_xxxxxx" path="/pages/home/home.html"><templete><div class="wx-btn">跳转小程序</div></templete></wx-open-launch-weapp>';
const launchBtn = document.getElementById('launch-btn') as Element;
if (!launchBtn) {
return
}
launchBtn.addEventListener('launch', function (e) {
console.log('launch',e);
})
launchBtn.addEventListener('error', function (e:any) {
console.log('fail', e.detail)
})
}
this.wxsdk.initConfig代码如下: [图片] Html代码 [图片] 线上图: [图片]