h5 打开小程序

1. jssdk  必须1.60 以上

2. 在wx.config 进行注册

wx.config({
                                debug: false,
                                appId: data.data.appid,
                                timestamp: data.data.timestamp,
                                nonceStr: data.data.noncestr,
                                signature: data.data.signature,
                                jsApiList: [
                                    'onMenuShareTimeline',
                                    'onMenuShareAppMessage',
                                    'updateAppMessageShareData',
                                    'updateTimelineShareData'
                                ],
                                openTagList: ["wx-open-launch-weapp"]  // 很重要
                            });

3. 使用 小程序标签 wx-open-launch-weapp

// template

<wx-open-launch-weapp
                                id="launch-btn"
                                username=""                  // 小程序原始id
                                path="pages/family/main"     // 小程序页面路径
                                >
                                <!-- <template>
                                    <style>.btn { padding: 12px }</style>
                                    <button class="btn">打开小程序</button>
                                </template> -->
                                <script type="text/wxtag-template">
                                    <img style="250px;height:45px;margin-left:15%;" class="btn" src="https://cdn.dianshihome.com/wechat/song/lookVipMore.png" alt="">
                                </script>
                            </wx-open-launch-weapp>

作者:人参,每篇随笔皆原创(除非注明原作者的随笔),欢迎指正!

原文地址:https://www.cnblogs.com/panax/p/14464690.html