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的样式**
  })
相关推荐
GISer_Jing3 小时前
Three.js着色器编译机制深度解析
javascript·webgl·着色器
丷丩3 小时前
MapLibre GL JS第22课:查看本地GeoJSON
前端·javascript·map·mapbox·maplibre gl js
油炸自行车3 小时前
Claude Code 错误:API Error: 400 Failed to deserialize the JSON body into the
开发语言·javascript·json·trae·claude code·api error 400
ZC跨境爬虫6 小时前
跟着 MDN 学CSS day_29:(掌握文本与字体样式的核心艺术)
前端·css·ui·html·tensorflow
丷丩7 小时前
MapLibre GL JS第19课:实时更新要素
前端·javascript·gis·map·mapbox·maplibre gl js
xiaohua0708day8 小时前
Lodash库
前端·javascript·vue.js
万物皆对象6668 小时前
切换路由时页面空白问题(vue3)
前端·vue.js·typescript
突然好热8 小时前
TS 调试技巧
前端·javascript·typescript
h64648564h8 小时前
Flutter 国际化(i18n)全指南:一键切换中/英/日多语言
前端·javascript·flutter
丷丩9 小时前
MapLibre GL JS第8课:禁用滚动缩放
javascript·mapbox·maplibre gl js