uniapp的一些特殊方法
获取头部导航安全区域
uni.getSystemInfoSync().statusBarHeight
编译环境
#ifdef MP 小程序编译环境
#ifdef H5 H5编译环境
#ifdef APP-PLUS APP编译环境
动态修改导航头部的标题
uni.setNavigationBarTitle({
title: '232432',
});
使用自带的下拉刷新,和上拉加载
{
"path": "pages/index/index",
"style": {
"enablePullDownRefresh": true,
"navigationBarTitleText": "首页"
}
},
onPullDownRefresh() {
this.page = 1;
this.getList(1);
},
onReachBottom() {
this.page++;
this.getList();
},
methods:{
getList() {
this.dataList = [{title:1}]
uni.stopPullDownRefresh();
},
},
打电话和复制
uni.makePhoneCall({
phoneNumber:'13123456789'
});
uni.setClipboardData({
data: '内容',
success: function () {},
});
打包成app后跳转浏览器
plus.runtime.openURL('https://baidu.com')
<template>
<view style="width: 100%;height: 100%;">
<web-view :webview-styles="webviewStyles" :src="url" :progress="false"></web-view>
</view>
</template>
<script>
export default {
data() {
return {
webviewStyles: {
progress: {
color: '#FF3333'
}
}
}
},
onLoad(e) {
console.log(e.url)
this.url = decodeURIComponent(e.url)
console.log(this.url)
},
methods: {
}
}
</script>
<style lang="less" scoped>
</style>
h5调试
<script src="//cdn.jsdelivr.net/npm/eruda"></script>
<script>eruda.init();</script>