uniapp从app端拉起微信小程序,APP打开微信小程序
onload里的代码:
// #ifdef APP-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); } var sweixin=shares['weixin']; that.setData({ sweixin:sweixin }) }, function(e){ console.log("获取分享服务列表失败:"+e.message); }); //#endif
sweixin需要放到data里去
data() { return { sweixin:'' }; }
method里:
kanshipin: function () { var n = this; //#ifdef APP-PLUS console.log(n.sweixin); n.sweixin?n.sweixin.launchMiniProgram({ id:'这个是你要打开的那个小程序原始id,长这样做gh_c306838810e9' }):plus.nativeUI.alert('当前环境不支持微信操作!'); //#endif }