1.弹窗
this.$u.toast('提示')
uni.showToast({
title: '内容', //提示的内容
uration: 2000, //持续的时间
con: 'loading', //图标有success、error、loading、none四种
mask: true //显示透明蒙层 防止触摸穿透
})
uni.showModal({
title: '我是标题', //提示的标题
content: '我是内容', //提示的内容
success: function(res) {
if(res.confirm) {
console.log('用户点击了确定')
} else if (res.cancel) {
console.log('用户点击了取消')
}
}
})
uni.showLoading({
title: '加载中',
})
uni.hideLoading()
2.路由跳转
// 无参数
uni.$u.route('/pages/components/empty/index');
// 带参数
uni.$u.route('/pages/components/empty/index', {
name: 'lisa',
age: 20
});
//删除本页面跳转
uni.redirectTo({
url: '路径',
})
//跳转tabbar
uni.switchTab({
url: '路径',
})
//返回上一页
uni.navigateBack({
delta: 1
});
//关闭所有页面跳转
uni.reLaunch({
url: '/pages/index/index',
})
3.页面模版(vue2)
<template>
<view class="main">
</view>
</template>
<script>
export default{
data(){
return{
}
},
onLoad() {
},
onShow() {
},
methods:{
}
}
</script>
<style>
view{
box-sizing: border-box;
}
</style>
<style lang="scss" scoped>
.main{
}
</style>
4.打开地图
uni.openLocation({
latitude: parseFloat(latitude),//纬度
longitude: parseFloat(longitude),//经度
scale: 18,//放大
name: name,//地点名称
address: address,//详细地址
})
5.返回一个Promise
async fn() {
return new Promise((resolve, reject) => {
resolve()
})
}