vue v-loading加载

使用v-loading在接口为请求到数据之前,显示加载中,直到请求到数据后消失。

//全局loading
<template>
    <div v-loading="loading"> </div>
</template>

在data 中定义初始化, loading: false,同时在mounted()中将 this.loading设置为true,再去请求接口

在接口的回调函数中,将 this.loading 设为false,到达效果。

如果写在template下的顶层元素上的话,就不会触发全屏loading

//局部loading
<template>
    <div> 
        <section v-loading="loading"></section>
    </div>
</template>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容