加载页面全局设置spinning

1.在app.vue 文件中设置

<template>
<a-config-provider :locale="zh_CN">
  <a-spin :spinning="spinning" tip="加载中..." size="large">
    <router-view/>
  </a-spin>
</a-config-provider>
</template>
<script>
import zh_CN from 'ant-design-vue/lib/locale-provider/zh_CN';
import moment from 'moment';
import 'moment/locale/zh-cn';

moment.locale('zh-cn');
export default {
  data() {
    return {
      zh_CN,
      spinning: false
    }
  },
  created(){
    this.$bus.$on("global-spinning", this.setSpinning)
  },
  methods: {
    setSpinning(spinning){
      this.spinning = spinning
    }
  }
}
</script>
<style lang="less">
html,body,#app{
  height: 100%;
}
.ant-spin-nested-loading{
  height: 100%;
}
.ant-spin-container{
  height: 100%;
}
</style>
 <style lang="less" src="@/assets/styles/zzwzui-basic.less"></style>

2.zzwzui-basicwenjian中写样式

// 加载中...
#app {
  // background: #000;
}

.ant-spin-spinning {
  position: absolute;
  top: calc(50% - 100px);
  left: 50%;
  z-index: 999999999999999999999;
  color: blue;
}

//旋转图标颜色
.ant-spin-lg .ant-spin-dot i {
  // background: #fff;
  background: blue;
}

.ant-spin-text{
  color: blue;

}


3.main.js引入

import VueBusPlugin from "./bus/bus"
Vue.use(VueBusPlugin)

4.添加bus.js文件

function VueBusPlugin(Vue) {
  const bus = new Vue()
  Object.defineProperty(Vue.prototype, '$bus', {
    get() {
      return bus
    }
  })
}

export default VueBusPlugin

5.在需要加载开始和加载暂停的地方控制开始和暂停
<-spin>在最外层
spinning设置初始值false
调用:

this.$bus.$emit("global-spinning", true);
        this.$bus.$emit("global-spinning", false);
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值