目前只实现了点击事件跳转,右上角分享到好友跳转到另一个小程序没实现
uniapp 相关文档:uni.navigateToMiniProgram
demo.vue
<template>
<view>
<button @click="handleAtoB">分享小程序</button>
</view>
</template>
<script>
export default {
methods: {
handleAtoB() {
uni.navigateToMiniProgram({
appId: "xxxxxxxxxx", // 要打开的小程序 appId
path: "/src/pages/my/xxx", // 打开的页面路径
extraData: {
key1: "value1",
},
/** envVersion
* 要打开的小程序版本:develop(开发版),trial(体验版),release(正式版)
* 仅在当前小程序为开发版或体验版时此参数有效。如果当前小程序是正式版,则打开的小程序必定是正式版。
*/
envVersion: "release",
success(res) {
console.log("跳转成功", res);
},
fail(err) {
console.error("跳转失败", err);
uni.showToast({
title: "跳转失败",
icon: "none",
});
},
});
},
},
};
</script>
manifest.json
增加如下代码:
"mp-weixin" : {
"appid" : "XXXX",
"navigateToMiniProgramAppIdList": [
"XXXXX" // 要打开的小程序 appId
],
"minVersion": "2.0.0", // 指定最低基础库版本
}