wx-open-launch-weapp跳转按钮没有显示
发布于 5 年前 作者 fengna 8880 次浏览 来自 问答

微信公从号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>

&lt;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>"&gt;&lt;/script&gt;

&lt;style type="text/css"&gt;

	div {

		width: 100%;

		height: 80px;

		border: 1px solid;

		background: greenyellow;

	}

&lt;/style&gt;

  </head>

  <body>

    <div>

	&lt;wx-open-launch-weapp id="launch-btn" username="gh\_XXXXXXXXXXXX"&gt;

	&lt;template&gt;

		&lt;style&gt;.btn { padding: 12px }&lt;/style&gt;

		&lt;button class="btn"&gt;打开小程序&lt;/button&gt;

	&lt;/template&gt;

	&lt;/wx-open-launch-weapp&gt;

&lt;/div&gt;

&lt;script&gt;

	window.onload = onready;

	function onready () {&nbsp;

 

		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); });

		}

	}

&lt;/script&gt;

  </body>

</html>

2 回复

请问解决了吗,我也遇到这个问题了

回到顶部