当前位置:首页 > 常见问题 > 前端

uni-app app跳转mini程序

来源:原创    更新时间:2024-02-29 15:21:54    编辑:管理员    浏览:466

记录uni-app 开发的App如何跳转mini程序

1. uni-app打开分享功能

13350377-d2d637acc00ba513.jpg
打开共享功能

2. 获取mini程序原始id

小程序的原始id获取url

13350377-21b8c8762363d782.jpg
点击设置
13350377-045c42f2cc0d5613.jpg
AppID(小程序ID)

3. coding

template

<view class="" @tap="test">1</view>


data

sweixin: ''

onLoad

let that = this
            // #ifdef APP-PLUS  
            console.log("plus");
            plus.share.getServices(function(s) {
                var shares = {};
                for (var i = 0; i < s.length; i++) {
                    var t = s[i];
                    console.log(t);
                    shares[t.id] = t;
                    console.log(t.id);
                }
                that.sweixin = shares['weixin']

            }, function(e) {
                console.log("获取分享服务列表失败:" + e.message);
            });
            //#endif


methods

test: function() {
                var n = this;
                //#ifdef APP-PLUS  
                console.log(n.sweixin);
                n.sweixin ? n.sweixin.launchMiniProgram({
                    id: '请填写mini程序的原始id',
                    type: 0, //小程序版本  0-正式版; 1-测试版; 2-体验版。
                    path: 'pages/home/home?id=' + 1 //小程序的页面,用传的参数在小程序接值判断跳转指定页面
                }) : plus.nativeUI.alert('当前环境不支持微信操作!');

                //#endif  
            },


作者:Xmaxdev
链接:https://www.jianshu.com/p/8689e4eb5240
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。