show-loading.uvue 1.3 KB
Newer Older
Y
yurj26 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
<template>
    <view>
        <page-head :title="title"></page-head>
        <view class="uni-padding-wrap">
            <view class="uni-btn-v">
                <button class="uni-btn" type="primary" @click="showLoading">显示 loading 提示框</button>
                <!-- #ifndef MP-ALIPAY -->
                <button class="uni-btn" @click="hideLoading">隐藏 loading 提示框</button>
                <!-- #endif -->
            </view>
        </view>
    </view>
</template>
<script lang="ts">
    export default {
        data() {
            return {
                title: 'loading'
            }
        },
        methods: {
            showLoading: function() {
                uni.showLoading({
                    title: 'loading'
                });

                // #ifdef MP-ALIPAY
                this._showTimer && clearTimeout(this._showTimer);
                this._showTimer = setTimeout(() => {
                    this.hideLoading();
                }, 3000)
                // #endif
            },
            hideLoading: function() {
                uni.hideLoading();
            }
        }
        // #ifdef MP-ALIPAY
        ,
        onUnload() {
            this._showTimer && clearTimeout(this._showTimer);
        }
        // #endif
    }
</script>