【发布时间】:2017-09-26 21:04:42
【问题描述】:
我正在使用 VueJS,我想将数据推送到服务器,然后更改路由。
我试过这个:
saveSupportArea: function () {
this.toast("success");
var that = this;
setTimeout(function(that){
that.$router.push('/areas/');
}, 3000);
});
但我收到此错误:
未捕获的类型错误:无法读取未定义的属性“$router”
有人可以帮忙吗?
【问题讨论】:
-
不要将
that作为匿名函数的参数传递给setTimeout -
天哪,它有效!你能解释为什么错了吗?和maaanyy谢谢! :) :D
标签: javascript vue.js vue-router