H5跳转小程序,签名通过点击跳转无反应?
发布于 7 年前 作者 fangdong 4721 次浏览 来自 问答

wx-open-launch-weapp 跳转小程序点击无反应,报错信息也没有回来。

	<div id="wechat-web-container" style="width: 100%;height: 100px;display: flex; align-items: center;justify-content: center;">

			<wx-open-launch-weapp id="launch-btn" username="小程序ID" path="/pages/index/index.html" [@error](/user/error)="handError"

			 [@launch](/user/launch)="handleLaunchFn">

				<template>

					<style>

						.wx-btn {

							width: 100px !important;

							height: 44px !important;

							line-height: 44px !important;

							font-size: 16px !important;

							color: \#ffffff !important;

							background-color: \#f94048 !important;

							text-align: center !important;

						}

					</style>

					<button class="wx-btn" style="border: 1px solid red !important;" [@click](/user/click)="handletest">跳转小程序</button>

				</template>

			</wx-open-launch-weapp>

		</div>

验签成功 增加

that.$wx.ready(res => {

							console.log(res);

							that.$nextTick(() => {

								let btn = document.getElementById('launch-btn');

								btn.addEventListener('launch', e => {

									console.log('success');

									alert('success');

								});

								btn.addEventListener('error', e => {

									alert('小程序打开失败');

									console.log('fail', e.detail);

									alert('fail', e.detail);

								});

							});

						});

回调函数

handleError(e) {

			console.log('fail', e.detail);

			alert('fail', e.detail);

		},

		handleLaunchFn(e) {

			console.log('success');

			alert('success');

		},

		handletest() {

			console.log('handletest');

			alert('handletest');

		}
3 回复

外部h5任意外链跳转微信打开小程序,参考案例 http://m.jumpwx.com/wx/?i=170

需要服务号配置js安全域名

是不是 还需要对应公众号配置什么东西,小程序是需要上架? 还有服务号绑定吗?

回到顶部