watch: {
$route() {
if (this.$route.path == '/plan/master' && this.$route.query.planName) {
// sessionStorage.setItem('oldworkorderName','');
var newName = this.$route.query.planName;//当前页新数据
// var oldName = this.formInline.planName;//旧的数据
var oldName = sessionStorage.getItem('oldplanName');//旧的数据
if (oldName != newName) {//数据有变化时
sessionStorage.setItem('oldplanName', this.$route.query.planName);
this.formInline.planName = this.$route.query.planName;
this.handleSearch()
}
}
}
},
//Echarts首页跳转
mounted: function () {
if (this.$route.query.planName) {
this.formInline.planName = this.$route.query.planName;
this.getPlanList();
sessionStorage.setItem('oldplanName', this.$route.query.planName);
} else {
//拉取列表接口
this.getPlanList();
}
通过watch监听路由信息 判断this.$route.query实例是否存在 然后将之前的数据存到页面缓存 根据存起来的数据进行判断 赋值后拉去数据
created只会在页面首次加载执行 因为页面有缓存 created 调用不生效 所以用mounted