VUE elememt-ui定时器不生效原因

vue 中,setTimeout() 函数中的 this 指向的并非vue对象,所以,定义一个_this 暂存 this,执行setTimeout函数时,setTimeout函数内的_this就会访问到这个变量,就会得到当前对象。

例如:

let _this=this; // 定义预存变量
setTimeout(function(){
   _this.$message({
  message: '批量操作成功',
    type: 'success'
  });
   _this.dialogVisible2 = false;
},3000);

原文地址:https://www.cnblogs.com/moguzi12345/p/12856334.html