ElementUI中MessageBox弹窗回调函数的用法

最近公司网站有个需求,需要一个弹出框提示。

选用了MessageBox,发现官方文档并没有回调的说明,自己类推了一下,在then里面回调了,action分别为confirm(确认),cancel(取消),close(关闭)的时候分别触发回调。

 

 1 upRisk(){
 2             if(this.userInfo.status==1){
 3                 this.fullscreenLoading = false,
 4                 this.$confirm('您的风险测评已经超过一年, 点击确定重新测评?', '提示', {
 5                   confirmButtonText: '确定',
 6                   cancelButtonText: '取消',
 7                   type: 'warning',
 8                   center: true
 9                 }).then((action) => {
10                         if(action === 'confirm'){
11                             this.$router.replace({path:'/account/risk_test'})
12                         }
13                 }).catch(() => {
14                   this.$message({
15                     type: 'info',
16                     message: '已取消重新测评'
17                   });
18                 });
19             }
20 
21         },

 

posted @ 2019-01-31 10:18  书生轻狂  阅读(13683)  评论(0编辑  收藏  举报