diff --git a/src/cache.js b/src/cache.js index 78d9ef4..391ce59 100644 --- a/src/cache.js +++ b/src/cache.js @@ -5,18 +5,18 @@ Vue.mixin({ if (this.$route.meta.keepAlive === true) { const result = this.$route.meta.keepAlive === true && store.state.tags.tagList.some(ele => { return ele.value === this.$route.fullPath; - }) + }); if (this.$vnode && !result) { if (this.$vnode.parent && this.$vnode.parent.componentInstance && this.$vnode.parent.componentInstance.cache) { if (this.$vnode.componentOptions) { - var key = this.$vnode.key == null + let key = this.$vnode.key == null ? this.$vnode.componentOptions.Ctor.cid + (this.$vnode.componentOptions.tag ? `::${this.$vnode.componentOptions.tag}` : '') : this.$vnode.key; - var cache = this.$vnode.parent.componentInstance.cache; - var keys = this.$vnode.parent.componentInstance.keys; + let cache = this.$vnode.parent.componentInstance.cache; + let keys = this.$vnode.parent.componentInstance.keys; if (cache[key]) { if (keys.length) { - var index = keys.indexOf(key); + let index = keys.indexOf(key); if (index > -1) { keys.splice(index, 1); } @@ -27,7 +27,6 @@ Vue.mixin({ } } } - next(); }, -}); \ No newline at end of file +}); diff --git a/src/views/work/process/leave/handle.vue b/src/views/work/process/leave/handle.vue index 20d7ead..7e88f95 100644 --- a/src/views/work/process/leave/handle.vue +++ b/src/views/work/process/leave/handle.vue @@ -13,25 +13,25 @@ 审批信息 - + - + - + - + - + @@ -89,6 +89,16 @@ created() { this.init(); }, + beforeRouteUpdate(to, from, next) { + // 在当前路由改变,但是该组件被复用时调用 + // 举例来说,对于一个带有动态参数的路径 /foo/:id,在 /foo/1 和 /foo/2 之间跳转的时候 + // 由于会渲染同样的 Foo 组件,因此组件实例会被复用。而这个钩子就会在这个情况下被调用 + // 可以访问组件实例 `this` + if (to.fullPath !== from.fullPath) { + next(); + this.init(); + } + }, methods: { init() { this.taskId = this.$route.params.taskId;