提交 67567e0d 编写于 作者: Mosher's avatar Mosher

视图消息组和视图消息组件增加定时关闭

上级 e778d36f
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
<app-alert <app-alert
:key="index" :key="index"
:tag="item.tag" :tag="item.tag"
:index="index"
:position="item.position"/> :position="item.position"/>
</template> </template>
</div> </div>
......
...@@ -17,8 +17,7 @@ import ViewMessageService from '../../message/view-message-service'; ...@@ -17,8 +17,7 @@ import ViewMessageService from '../../message/view-message-service';
@Component({}) @Component({})
export default class AppAlert extends Vue { export default class AppAlert extends Vue {
/** /**
* 视图消息标识 * 视图消息标识
* *
...@@ -34,14 +33,6 @@ export default class AppAlert extends Vue { ...@@ -34,14 +33,6 @@ export default class AppAlert extends Vue {
* @memberof AppAlert * @memberof AppAlert
*/ */
@Prop() position: any; @Prop() position: any;
/**
* 视图消息显示次序
*
* @type {any}
* @memberof AppAlert
*/
@Prop() index: any;
/** /**
* 视图消息对象 * 视图消息对象
...@@ -115,6 +106,14 @@ export default class AppAlert extends Vue { ...@@ -115,6 +106,14 @@ export default class AppAlert extends Vue {
*/ */
public hasContent: boolean = true; public hasContent: boolean = true;
/**
* 显示时长(秒)
*
* @type {boolean}
* @memberof AppAlert
*/
public duration: number = 3;
/** /**
* Vue生命周期 * Vue生命周期
* *
...@@ -148,6 +147,26 @@ export default class AppAlert extends Vue { ...@@ -148,6 +147,26 @@ export default class AppAlert extends Vue {
this.handlePosition(flag); this.handlePosition(flag);
} }
/**
* Vue生命周期
*
* @memberof AppAlert
*/
public mounted() {
this.afterMounted();
}
/**
* 组件挂载之后
*
* @memberof AppAlert
*/
public afterMounted() {
setTimeout(() => {
this.showState = false;
}, this.duration * 1000);
}
/** /**
* 获取视图消息对象 * 获取视图消息对象
* *
...@@ -210,8 +229,9 @@ export default class AppAlert extends Vue { ...@@ -210,8 +229,9 @@ export default class AppAlert extends Vue {
type: this.data.type, type: this.data.type,
showClose: this.closable, showClose: this.closable,
onClose: this.alertClose, onClose: this.alertClose,
duration: this.duration * 1000,
}) })
}, Number(this.index)*1000) }, 0)
} else { } else {
this.title = this.data.title; this.title = this.data.title;
this.message = this.data.content; this.message = this.data.content;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册