uniapp常用方法

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()
	})
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值