vue中全局引入loading并使用

1.创建loading.vue文件

<template>
  <div class="loading"></div>
</template>
<script>
export default {
  name: "loading"
};
</script>
<style lang="scss" scoped>
.loading {
  overflow: hidden;
  position: fixed;
  left: 0;
  top: 0;
  background: url("https://goplastic.oss-cn-beijing.aliyuncs.com/goplasticCommon/loading.gif")
    center center no-repeat rgba($color: #000000, $alpha: .5);
  background-size: 3%;
  width: 100%;
  height: 100%;
  z-index: 1000;
}
</style>

2.main.js中引入并挂载

import loading from "@/components/loading";

Vue.component("loading",loading);

3.页面使用

<loading v-if="isLoading"></loading>
//初始化  isLoading=true 数据加载完=false
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 一:什么是闭包?闭包的用处? (1)闭包就是能够读取其他函数内部变量的函数。在本质上,闭包就 是将函数内部和函数外...
    xuguibin阅读 10,080评论 1 52
  • 1. 组件的data为什么必须是函数? 组件中的 data 写成一个函数,数据以函数返回值形式定义,这样每复用一次...
    郭先生_515阅读 1,071评论 0 12
  • 一、 组件component 1. 什么是组件? 组件(Component)是 Vue.js 最强大的功能之一。组...
    饥人谷_Leonardo阅读 2,210评论 0 18
  • 1、active-class是哪个组件的属性?嵌套路由怎么定义?答:vue-router模块的router-lin...
    jane819阅读 1,852评论 0 15
  • 儿子:妈妈,你再给我做个果盘吧?妈妈:累了,不想做了。儿子:妈妈,快去吧,你不是美食家吗?这对于你来说也不算个事儿...
    爱玛的微笑阅读 350评论 0 2

友情链接更多精彩内容