signed

QiShunwang

“诚信为本、客户至上”

app 跳转小程序

2021/4/26 14:53:36   来源:
<template>
    <view>
        <button @click="nav">跳转小程序</button>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                sweixin: 'weixin'
            }
        },
        onLoad() {
            var that = this
            // #ifdef APP-PLUS
            plus.share.getServices(function(s) {
                for (var i = 0; i < s.length; i++) {
                    var t = s[i];
					if (t.id == 'weixin') {
						that.sweixin = t;
					}
                }
            }, function(e) {
                console.log("获取分享服务列表失败:" + e.message);
            });
            //#endif
        },
        methods: {
            nav() {
                var n = this;
                console.log('n ===== ', n.sweixi)
                //#ifdef APP-PLUS
                console.log('sweixin ===== ', n.sweixin);
                n.sweixin ? n.sweixin.launchMiniProgram({
                    id: 'gh_bdad127a996f' // 要修改
                }) : plus.nativeUI.alert('当前环境不支持微信操作!');
                //#endif
            }

        }
    }
</script>