wx-open-launch-weapp跳转按钮没有显示
微信公从号H5跳转小程序,wx.config已弹出“config:ok”,但是页面上wx-open-launch-weapp标签大小为0x0,“打开小程序”这个按钮没有显示出来,请问是什么原因?
代码:
<!DOCTYPE html>
<html lang=“en”>
<head>
<meta charset=“utf-8” />
<meta name=“viewport” content=“minimum-scale=1, initial-scale=1, width=device-width” />
<title>weapp</title>
<script src="<a href="https://res.wx.qq.com/open/js/jweixin-1.6.0.js" rel="noopener noreferrer" target="_blank">https://res.wx.qq.com/open/js/jweixin-1.6.0.js</a>"></script>
<style type="text/css">
div {
width: 100%;
height: 80px;
border: 1px solid;
background: greenyellow;
}
</style>
</head>
<body>
<div>
<wx-open-launch-weapp id="launch-btn" username="gh\_XXXXXXXXXXXX">
<template>
<style>.btn { padding: 12px }</style>
<button class="btn">打开小程序</button>
</template>
</wx-open-launch-weapp>
</div>
<script>
window.onload = onready;
function onready () {
var btn = document.getElementById('launch-btn');
btn.addEventListener('launch', function (e) {
console.log('success');
});
btn.addEventListener('error', function (e) {
console.log('fail', e.detail);
});
var wxBrower = false;
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i)=='micromessenger') {
wxBrower = true;
}
alert(ua);
if (wxBrower) {
wx.config({
debug: true,
appId: 'wxXXXXXXXXXXXXXXX',
nonceStr: '123456',
timestamp: 1604560136120,
signature: '0dcbc0a225a4a487b2ea51f4c04e8d4d814183d2',
jsApiList: \["onMenuShareTimeline", "onMenuShareAppMessage", "checkJsApi", "scanQRCode"\],
openTagList: \['wx-open-launch-weap'\]
});
wx.ready(function () { alert("wx ready"); });
wx.error( function () { alert("wx error: "+ err); });
}
}
</script>
</body>
</html>
2 回复