微信浏览器中打开小程序
wx-open-launch-weapp
http://res.wx.qq.com/open/js/jweixin-1.6.0.js
wx.config({
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: appId, // 必填,公众号的唯一标识
timestamp: timestamp, // 必填,生成签名的时间戳
nonceStr: nonceStr, // 必填,生成签名的随机串
signature: signature, // 必填,签名
jsApiList: [
'updateAppMessageShareData',
'updateTimelineShareData',
'onMenuShareAppMessage',
'onMenuShareTimeline'
], // 必填,需要使用的JS接口列表
openTagList: ['wx-open-launch-weapp'],//配置
});
gh_Id 小程序原始id
path /pages/user-center/index.html 拼接 .html
env-version 版本默认正式版
const renderOpenMini = () => {
if (isWeixin) {
return (
<wx-open-launch-weapp id="launch-btn" username={gh_Id} path={path} env-version='trial' >
<script type="text/wxtag-template">
<button
style={{
marginTop: '28px',
fontSize: '18px',
width: '215px',
textAlign: 'center',
color: '#fff',
lineHeight: '36px',
borderRadius: '18px',
background: `#07c160`,
border: 'none',
outline: 'none',
}}
>
打开小程序
</button>
</script>
</wx-open-launch-weapp>
);
}
return <Text className="normal-text">请在微信浏览器中打开此页面</Text>;
};URL Scheme
官方文档
https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/url-scheme.html
1. 获取access_token
https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-access-token/getAccessToken.html
2. 获取加密URL Scheme
3. 注意事项:
跳转的path必须是正式版存在的
跳转的版本只有在微信外生效,即在微信下跳转始终跳转正式版本
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果