// 退出页面前将data中不为空的值到存到sessionstorage中,在进入页面时判断本地是否有当前页面name,有则赋值无则正常刷新
// 存store也可
beforeRouteLeave(to, form, next) {
console.log(this)
let a = [],
b = {}
let reg = /^(?![\$,_,__,rowStyle]).*/
for (var key in this) {
if (
typeof this[key] !== 'function' &&
this[key] !== '' &&
reg.test(key)
) {
if (Array.isArray(this[key]) && this[key].length == 0) {
} else {
b[key] = this[key]
}
} else {
}
}
sessionStorage.setItem(this.$options.name, JSON.stringify(b))
next()
},
mounted: function() {
if (sessionStorage.getItem(this.$options.name)) {
console.log(JSON.parse(sessionStorage.getItem(this.$options.name)))
let a = JSON.parse(sessionStorage.getItem(this.$options.name))
for (var key in a) {
this[key] = a[key]
}
sessionStorage.removeItem(this.$options.name);
} else {
this.auditType = 1
this.enterTableQuery()
}
},