1. h5跳轉小程序有兩種情況
(1)從普通瀏覽器打開的h5頁面跳轉小程序使用wx-open-launch-weapp可以實現h5跳轉小程序
<wx-open-launch-weappstyle="display:block;"v-elseid="launch-btn":username="wechatYsAppid":path="path"><script type="text/wxtag-template"><style>.btn {width: 100%;height: 48px;margin-top: 21px;font-size: 18px;color: #FFFFFF;line-height: 48px;text-align: center;border-radius: 15px;background-color: #01CB88;font-weight: 500;border:none;}</style><button class="btn">跳轉小程序</button></script></wx-open-launch-weapp>
(2)從小程序環境中的H5頁面(也就是從小程序中通過web-view跳轉到的H5頁面)跳到小程序
//先判斷當前頁面所處環境是否為微信內置瀏覽器,如果是則代表是web-view頁面,則使用://是否是微信內置瀏覽器
var ua = window.navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == 'micromessenger') {console.log("micromessenger"); //微信內置瀏覽器
wx.miniProgram.navigateTo({url: `/pages/books/index?AuthOauthToken=${AuthOauthToken}&productId=[10]&source=takes`, // 小程序內頁面路徑及查詢參數success:function(res) {},fail:function(res) {}});
}
3.小程序跳轉其他小程序,使用wx.navigateToMiniProgram()跳轉
let path=`pages/sys/booksAuthOauthToken=${AuthOauthToken}&productId=${productId}&to=${encodeURIComponent('/pages/look/index')}&productId=[3,4]`;uni.navigateToMiniProgram({// 某某小程序appId: this.$httpWX.azAppId,path: path,query: {AuthOauthToken: AuthOauthToken,origin: "fff",to: encodeURIComponent('/pages/look/index')},envVersion: this.$httpWX.envVersion,success: (res) => {},fail: (fail) => {uni.showToast({icon: "none",title: '您已取消'})uni.switchTab({url: "/pages/Main/main"})}})
4.小程序跳轉H5
使用web-view標簽跳轉,這里先不多做介紹~~