美文网首页
uni-app点击按钮显示 loading 提示框-uni.sh

uni-app点击按钮显示 loading 提示框-uni.sh

作者: 祈澈菇凉 | 来源:发表于2021-06-30 00:01 被阅读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>
    
    

    相关文章

      网友评论

          本文标题:uni-app点击按钮显示 loading 提示框-uni.sh

          本文链接:https://www.haomeiwen.com/subject/msjkultx.html