优化loading组件
This commit is contained in:
parent
f0d16446c4
commit
3ac3f53338
|
@ -44,7 +44,7 @@ export default {
|
||||||
width: 270rpx;
|
width: 270rpx;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
transform: translateY(-50%);
|
transform: translateY(-50%);
|
||||||
background-color: #646464;
|
background-color: #4e4e4e;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 20rpx;
|
padding: 20rpx;
|
||||||
border-radius: 10rpx;
|
border-radius: 10rpx;
|
||||||
|
|
|
@ -1,12 +1,21 @@
|
||||||
import $store from '@/store/index'
|
import $store from '@/store/index'
|
||||||
export default {
|
export default {
|
||||||
|
timer: null,
|
||||||
|
timeout: 10,
|
||||||
show(title) {
|
show(title) {
|
||||||
|
clearTimeout(this.timer);
|
||||||
$store.commit('loading/show', true);
|
$store.commit('loading/show', true);
|
||||||
if (title) {
|
if (title) {
|
||||||
$store.commit('loading/title', title);
|
$store.commit('loading/title', title);
|
||||||
}
|
}
|
||||||
|
// 10秒后自动hide
|
||||||
|
let that = this;
|
||||||
|
this.timer = setTimeout(() => {
|
||||||
|
that.hide();
|
||||||
|
}, this.timeout * 1000);
|
||||||
},
|
},
|
||||||
hide() {
|
hide() {
|
||||||
|
clearTimeout(this.timer);
|
||||||
$store.commit('loading/show', false);
|
$store.commit('loading/show', false);
|
||||||
$store.commit('loading/title', "");
|
$store.commit('loading/title', "");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue