export default {
|
data() {
|
return {
|
pageFlag: 0,
|
};
|
},
|
beforeRouteEnter(to, from, next) {
|
next((vm) => {
|
// 由于页面跳转后,在跳转页面筛选后,切换页面后会自动恢复,因此跳转页面需要定义一个方法refreshFN 在里面定义需要执行的代码
|
if (vm.refreshFN && "function" == typeof vm.refreshFN) {
|
// let pageFlag = vm.$route.query.pageFlag
|
// ? Number(vm.$route.query.pageFlag)
|
// : 0;
|
// console.log(pageFlag + "&&&&&" + vm.pageFlag, vm.$data);
|
// if (pageFlag !== vm.pageFlag) {
|
// console.log('refresh');
|
// vm.refreshFN();
|
// // vm.pageFlag = pageFlag;
|
// }
|
// 新版本此处获取不到vm实例的响应属性 故改为在页面refreshFN中判断
|
vm.refreshFN();
|
}
|
|
// 由于页面从非激活状态激活时 不会触发mounted 如果有需求需要定义一个方法 activeFN 在里面定义需要执行的代码
|
if (vm.activeFN && "function" == typeof vm.activeFN) {
|
vm.activeFN();
|
}
|
});
|
},
|
activated() {
|
// 如果有websocket 则初始化
|
if (this.openSocket && "function" == typeof this.openSocket) {
|
this.openSocket();
|
}
|
},
|
deactivated() {
|
// 如果有 则关闭websocket
|
if (this.WSClose && "function" == typeof this.WSClose) {
|
this.WSClose();
|
}
|
// TODO
|
if (this.refreshFN && "function" == typeof this.refreshFN) {
|
let pageFlag = this.$route.query.pageFlag
|
? Number(this.$route.query.pageFlag)
|
: 0;
|
console.log(pageFlag, 'deactive');
|
// this.pageFlag = pageFlag;
|
}
|
},
|
};
|