<template> <view> <view class="main-btn" @click="toPage(courseUrl)"> <image src="/static/edu-icon/course.png"></image> <text>培训课程</text> </view> <view class="main-btn" @click="toOtherApp"> <image src="/static/edu-icon/net.png"></image> <text>网络教育</text> </view> </view> </template> <script> export default { data() { return { netAppid: "", courseUrl: "/pages/goOnEdu/course/index" }; }, methods: { toOtherApp() { if (this.netAppid === "") { uni.showToast({ title: "跳转其他小程序", icon: "none" }) return; } uni.navigateToMiniProgram({ appId: this.netAppid, // 替换为你要跳转的小程序的AppID path: '', // 目标小程序的页面路径,留空则默认为首页 extraData: { foo: 'bar' // 传递给目标小程序的数据(可选) }, envVersion: 'release', // 指定要打开的小程序版本: release 或 trial success(res) { console.log('成功跳转到小程序', res); }, fail(err) { console.error('跳转失败', err); } }); }, toPage(url){ uni.navigateTo({ url:url }) } } } </script> <style lang="scss"> .main-btn { width: 85%; background-color: #006af4; border-radius: 20rpx; margin: 30rpx auto; padding: 40rpx 30rpx; display: flex; align-items: center; image { width: 100rpx; height: 100rpx; flex: 0 0 auto; } text { margin-left: 20rpx; color: #fff; font-size: 40rpx; } } </style>