loading效果

指令方式
// html中, 通过设置fullscreenLoading的状态来开启和关闭loading效果,可以在css中设置背景色的透明度
<el-button @click="openFullScreen1" v-loading.fullscreen.lock="fullscreenLoading">指令方式</el-button>
// data
data() {
	fullscreenLoading: false
}
//script
openFullScreen1() {
			this.fullscreenLoading = true;
			setTimeout(() => {
				this.fullscreenLoading = false;
			}, 2000);
		},
// css 
.el-loading-mask {
  background-color: rgba(255, 255, 255, 0.1) ;
}
服务方式
//html
<el-button type="primary" @click="openFullScreen2">
			服务方式
</el-button>
// script
openFullScreen2() {
				const loading = this.$loading({
					lock: true,
					text: '拼命加载中',// 修改显示文字
					spinner: 'el-icon-loading',//可以设置图标
					background: 'rgba(255, 255, 255, 0.9)'
				});
				setTimeout(() => {
					loading.close();
				}, 2000);
			},
下载外部插件

安装插件 npm install vue-element-loading --save

// 引用
import VueElementLoading from 'vue-element-loading'
components: {
			VueElementLoading
		},
// html
<vue-element-loading :active="isActive" spinner="bar-fade-scale" color="#FF6700" />
<el-button @click="toLoad">加载</el-button>
// data
data() {
	isActive: false,
}
// script
// 开启加载,设置时间关闭加载, 可以设置color改变图标的颜色
toLoad() {
				this.isActive = true
				setTimeout(() => {
					this.isActive = false
				}, 2000);
				console.log(this.isActive)
			},

效果:
在这里插入图片描述

GitHub 加速计划 / eleme / element
14
2
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:2 个月前 )
c345bb45 1 年前
a07f3a59 * Update transition.md * Update table.md * Update transition.md * Update table.md * Update transition.md * Update table.md * Update table.md * Update transition.md * Update popover.md 1 年前
Logo

新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐