Commit 96a57b10 authored by wdy's avatar wdy

再利用数据缓存

parent e35341a2
...@@ -71,7 +71,7 @@ export default { ...@@ -71,7 +71,7 @@ export default {
data() { data() {
return { return {
// 缓存判断 // 缓存判断
exist: false, recycleexist: false,
form: { form: {
pn: '', pn: '',
lot: '', lot: '',
...@@ -121,14 +121,13 @@ export default { ...@@ -121,14 +121,13 @@ export default {
}, },
// 路由跳转,是存储页面的值 // 路由跳转,是存储页面的值
beforeRouteLeave(to, from, next) { beforeRouteLeave(to, from, next) {
console.log('form') sessionStorage.setItem('recycleform', JSON.stringify(this.form))
localStorage.setItem('form', JSON.stringify(this.form))
next() next()
}, },
created() { created() {
localStorage.getItem('form') ? this.exist = true : this.exist = false sessionStorage.getItem('recycleform') ? this.recycleexist = true : this.recycleexist = false
if (this.exist) { if (this.recycleexist) {
this.form = JSON.parse(localStorage.getItem('form')) this.form = JSON.parse(sessionStorage.getItem('recycleform'))
} }
}, },
methods: { methods: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment