准备工作
有些手机会唤起失败,直接唤起了全屏的小程序,所以我们为了兼容,需要在app.config.ts加上
{
"embeddedAppIdList": ["wxxxxxxxx"]//appid 是你要跳转到的小程序的 appid。
}
跳转方式
export const openHalfMini = () => {
const platform = wx.getSystemInfoSync().platform
if (platform !== 'android') {
wx.showLoading({
title: '打开小程序中',
mask: true
})
}
const token = wx.getStorageSync('token')
wx.openEmbeddedMiniProgram({
// 要跳转的小程序的appid
appId: 'wxcfxxxx',
envVersion: __ENV__ !== 'production' ? 'trial' : 'release',
path: `/pages/index/index?id=xxx`,
success: () => {},
fail: (error) => {
console.log('跳转小程序失败', error)
},
complete: () => {
wx.hideLoading()
}
})
}