自学内容网 自学内容网

uniapp,一些功能分享

联系客服

<button open-type="contact" class="butt"></button>

微信公众号(跳转)

<official-account style="position: absolute;left: 0;top: 0;
opacity: 0; width:100%;height: 100%;"></official-account>

小程序跳转到另一个小程序

wx.navigateToMiniProgram({
appId: res.data.appid,
path: res.data.page,
envVersion: 'release',
success(res) {
}
});

网站跳转


wx.navigateTo({
  url: 'https://www.baidu.com'
})
//带参数

wx.navigateTo({
  url: 'https://www.baidu.com/s?wd=小程序'
})
也可以通过web-view组件将H5页面嵌入小程序中展示。具体操作如下:

在小程序页面的json文件中引入web-view组件
{
  "usingComponents": {
    "web-view": "/path/to/web-view/component"
  }
}
在小程序页面WXML文件中添加web-view组件
<web-view src="https://www.example.com"></web-view>

微信扫码进入小程序

onLoad(e) {
if (e.q) {
this.query = decodeURIComponent(e.q)
console.warn(this.query)
this.qtype = this.getQueryString('t')
if (this.qtype != 's') {
uni.reLaunch({
url: "/pages/index/index"
})
return false;
}
this.code = this.getQueryString('c')
console.warn(this.code)
console.warn(this.qtype)
// this.hodmindex()
}
},

小程序扫码的两种情况

// 继续扫码
scan() {
var that = this
uni.scanCode({
success: function(res) {
const params = {};
const regex = /[?&](t|c)=([^&]*)/g;
let match;
while ((match = regex.exec(res.result)) !== null) {
params[match[1]] = match[2];
}
that.code = params.c
that.qtype = params.t
}
});
},

获取经纬度


原文地址:https://blog.csdn.net/maliao5/article/details/142548388

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!