vue 组件全局封装_vue封装页面全局加载子组件

1. 首先我们看一下 Element 中的加载方式,设置加载配置

openFullScreen2() {

const loading = this.$loading({

lock: true,

text: 'Loading',

spinner: 'el-icon-loading',

background: 'rgba(0, 0, 0, 0.7)'

});

setTimeout(() => {

loading.close();

}, 2000);

}

}

text 是要显示的文字,spinner 是显示的图标

2.在封装组件之前我们需要看一下文档

3.创建loading.js 文件

import { Loading } from 'element-ui';

// 引入 加载图标 loading

// 设置 加载的数据

let loadingCount = 0;

let loading;

const startLoading = () => {

loading = Loading.service({

lock: true,

text: '任务下发中······',//可以自定义文字

spinner:'el-icon-loading',//自定义加载图标类名

background: 'rgba(0, 0, 0, 0.7)'//遮罩层背景色

});

};

const endLoading = () => {

loading.close();

};

export const showLoading = () => {

if (loadingCount === 0) {

startLoading();

}

loadingCount += 1;

};

export const hideLoading = () => {

if (loadingCount <= 0) {

return;

}

loadingCount -= 1;

if (loadingCount === 0) {

endLoading();

}

};

4. 在页面中引入

标签:spinner,loading,const,Loading,vue,封装,loadingCount,加载

来源: https://www.cnblogs.com/tdcqcrtd/p/13985684.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值