vue中加全局loading并添加自定义加载语
首先在模板页最外层标签添加绑定< template v-loading=“loading”>导入import {Loading} from ‘element-ui’定义字段初始值:loading: false加载调用startLoading() {this.loading =Loading.service({lock: true,// text: ‘加载中倒计时:...
首先在模板页最外层标签添加绑定
< template v-loading=“loading”>
导入
import {Loading} from ‘element-ui’
定义字段初始值:
loading: false
加载调用
startLoading() {
this.loading =Loading.service({
lock: true,
// text: ‘加载中倒计时:’+this.count,
background: ‘rgba(190, 190, 190, 0.5)’
})
},
setTimer() {
let endMsRes = (new Date()).getTime() + 60000;
this.codeCountDown(endMsRes)
},
codeCountDown ( endMsRes) {
this.count= Math.ceil((endMsRes - (new Date()).getTime()) / 1000)
let time = setTimeout(() => {
this.count–;
this.loading.text="拼命加载中: "+this.count//放置定时计数
if (this.count< 1) {//判断60秒后停止loading
this.loading.close();
//this.loading=false;
this.radioChange();
this.count= 60
} else {
this.codeCountDown(endMsRes)//利用回调完成计数
}
}, 1000)
},
更多推荐
所有评论(0)