H5+ API

  • uni-app不需要 plus ready

  • Uni-app 不支Native.js 执行UI相关操作的API调用及webview相关API调用。将失效无法正常使用。Uni-app不推荐使用Native.js

事件监听

1
2
3
4
// #ifdef APP-PLUS
// 监听设备网络状态变化事件
plus.globalEvent.addEventListener('netchange', function(){});
// #endif

打开浏览器新窗口

1
2
var url = 'http://115.28.211.10/1.docx';
plus.runtime.openURL('http://ip地址:8888/kkfileview/onlinePreview?url='+encodeURIComponent(Base64.encode(url)));

地图

使用应用内置地图查看位置

  • uni.openLocation(OBJECT)

  • 坐标要转换为 gcj02 国测局坐标系

  • 如果想在地图上使用高德地图导航,则先安装高德地图

打开地图选择位置-默认自动定位、支持搜索

  • uni.chooseLocation 获取的坐标为 gcj02
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<template>
<view class="content">
<button type="default" @click="chooseLocation">定位</button>
<view>
<map :longitude="longitude" :latitude="latitude" style="width: 200px; height: 150px;"></map>
</view>
</view>
</template>

<script>
export default {
data() {
return {
longitude: '',
latitude: ''
}
},
onLoad() {},
methods: {
chooseLocation() {
uni.chooseLocation({
success: (res) => {
this.longitude = res.longitude;
this.latitude = res.latitude;
console.log('位置名称:' + res.name);
console.log('详细地址:' + res.address);
console.log('纬度:' + res.latitude);
console.log('经度:' + res.longitude);
}
})
}
}
};
</script>

网络

上传、下载

https://uniapp.dcloud.net.cn/api/request/network-file?id=uploadfile

界面

https://uniapp.dcloud.net.cn/api/README?id=%e7%95%8c%e9%9d%a2

交互反馈

https://uniapp.dcloud.net.cn/api/README?id=交互反馈

设置导航条

设置 TabBar

动态设置窗口的背景色、下拉背景字体、loading 图的样式

将页面滚动到目标位置

uni.request

uni.request 返回数据格式:data 部分是后台返回的业务数据

96BFE6554265C3F20DC3764F965F5D7B