element-ui 中修改loading加载样式

element-ui 中的 loading 加载功能,默认是全屏加载效果

设置局部,需要自定义样式或者修改样式,方法如下:

javascript 复制代码
import { Loading } from 'element-ui'
 
 
Vue.prototype.$baseLoading = (text) => {
    let loading
    loading = Loading.service({
       lock: true,
       customClass: 'createLoading',  // 局部class名称
       text: text,
       spinner: 'el-icon-loading',
       background: 'rgba(0, 0, 0, 0)'
    })
  return loading
}
 
<style lang="scss">
  .createLoading {
    .el-loading-spinner {
      top: 50%;
      left: 50%;
      margin-left: -55px;
      background: rgba(0, 0, 0, 0.7);
      padding: 20px;
      border-radius: 4px;
      width: auto;
      text-align: center;
      position: absolute;
 
      i {
        color: #eee;
      }
 
      .el-loading-text {
        color: #eee;
      }
    }
  }
</style>
 

重点:createLoading有这个局部class名字就能控制样式的修改,有时候::v-deep在loading中不能修改样式

一些属性参数:

javascript 复制代码
const loading = this.$loading({           // 声明一个loading对象
    lock: true,                             // 是否锁屏
    text: '加载中',                         // 加载动画的文字
    spinner: 'el-icon-loading',             // 引入的loading图标
    background: 'rgba(0, 0, 0, 0.8)',       // 背景颜色
    target: '.el-table, .table-flex, .region',  // **需要遮罩的区域,这里写要添加loading的选择器**
    fullscreen: false,
    customClass: 'loadingclass'             // **遮罩层新增类名,如果需要修改loading的样式**
  })
相关推荐
rui锐rui28 分钟前
商品销售数据分析实验
vue.js·数据挖掘·数据分析
伍哥的传说29 分钟前
H3初识——入门介绍之常用中间件
前端·javascript·react.js·中间件·前端框架·node.js·ecmascript
AA-代码批发V哥31 分钟前
JavaScript之数组方法详解
javascript
洛小豆1 小时前
深入理解Pinia:Options API vs Composition API两种Store定义方式完全指南
前端·javascript·vue.js
Jokerator1 小时前
Vue 2现代模式打包:双包架构下的性能突围战
javascript·vue.js
洛小豆1 小时前
JavaScript 对象属性访问的那些坑:她问我为什么用 result.id 而不是 result['id']?我说我不知道...
前端·javascript·vue.js
bug爱好者1 小时前
原生小程序如何实现跨页面传值
前端·javascript
bug爱好者1 小时前
原生微信小程序最实用的工具函数合集
前端·javascript
3Katrina2 小时前
JS事件机制详解(2)--- 委托机制、事件应用
前端·javascript·面试
前端wchen2 小时前
Vue 3 组件通信实战系列(一)父子组件通信的标准姿势:Props 与 Emit(含实战与进阶技巧)
前端·vue.js