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的样式**
  })
相关推荐
ShenJLLL18 小时前
vue部分知识点.
前端·javascript·vue.js·前端框架
Never_Satisfied1 天前
在JavaScript / HTML中,数组查找第一个符合要求元素
开发语言·javascript·html
HelloReader1 天前
Tauri 2 创建项目全流程create-tauri-app 一键脚手架 + Tauri CLI 手动接入
前端·javascript·vue.js
shix .1 天前
旅行网站控制台检测
开发语言·前端·javascript
哆啦A梦15881 天前
Vue3魔法手册 作者 张天禹 016_vue3中一些特定用法介绍
前端·vue.js·typescript
henry1010101 天前
DeepSeek生成的网页小游戏 - 迷你高尔夫
前端·javascript·游戏·html
薛一半1 天前
React的组件
前端·javascript·react.js
薛一半1 天前
React三大属性之props
前端·javascript·react.js
计算机毕设VX:Fegn08951 天前
计算机毕业设计|基于springboot + vue连锁门店管理系统(源码+数据库+文档)
数据库·vue.js·spring boot·后端·课程设计