uni-app点击按钮显示 loading 提示框-uni.sh
2021-06-30 本文已影响0人
祈澈菇凉
uni.showLoading(OBJECT)
显示 loading 提示框, 需主动调用 uni.hideLoading 才能关闭提示框。
参考文档
https://uniapp.dcloud.io/api/ui/prompt?id=showmodal
一些参数说明:

test.vue例子
<template>
<button @click.stop="isLeave()">点击按钮</button>
</template>
<script>
export default {
data() {
return {};
},
onLoad() {},
methods: {
isLeave(id) {
uni.showLoading({
title: '加载中'
});
},
},
}
</script>
<style>
</style>

这里需要搭配uni.hideLoading()一起使用
设置加载两秒之后,隐藏一下加载框
<template>
<button @click.stop="isLeave()">点击按钮</button>
</template>
<script>
export default {
data() {
return {};
},
onLoad() {},
methods: {
isLeave(id) {
uni.showLoading({
title: '加载中'
});
setTimeout(function () {
uni.hideLoading();
}, 2000);
},
},
}
</script>
<style>
</style>