@@ -27,6 +27,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="d2-multiple-page-control-btn" flex-box="0">
|
<div class="d2-multiple-page-control-btn" flex-box="0">
|
||||||
|
<el-button @click="handleRefresh">
|
||||||
|
<d2-icon name="refresh"/>
|
||||||
|
</el-button>
|
||||||
<el-dropdown
|
<el-dropdown
|
||||||
size="default"
|
size="default"
|
||||||
split-button
|
split-button
|
||||||
@@ -97,6 +100,14 @@ export default {
|
|||||||
'closeAll',
|
'closeAll',
|
||||||
'openedSort'
|
'openedSort'
|
||||||
]),
|
]),
|
||||||
|
/**
|
||||||
|
* @description 仅刷新当前router组件 不影响其他已缓存的组件
|
||||||
|
*/
|
||||||
|
handleRefresh () {
|
||||||
|
this.$router.push({
|
||||||
|
name: 'refresh'
|
||||||
|
})
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* @description 计算某个标签页是否可关闭
|
* @description 计算某个标签页是否可关闭
|
||||||
* @param {Object} page 其中一个标签页
|
* @param {Object} page 其中一个标签页
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
<div class="d2-theme-container-main-body" flex-box="1">
|
<div class="d2-theme-container-main-body" flex-box="1">
|
||||||
<transition :name="transitionActive ? 'fade-transverse' : ''">
|
<transition :name="transitionActive ? 'fade-transverse' : ''">
|
||||||
<keep-alive :include="keepAlive">
|
<keep-alive :include="keepAlive">
|
||||||
<router-view/>
|
<router-view :key="$route.path + $route.meta[$route.path]" />
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
</transition>
|
</transition>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -39,38 +39,8 @@ export default {
|
|||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
datas: [],
|
|
||||||
data: { value: '' }
|
data: { value: '' }
|
||||||
}
|
}
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
switchData (id) {
|
|
||||||
let data = this.datas[id]
|
|
||||||
if (!data) {
|
|
||||||
data = { value: '' }
|
|
||||||
this.datas[id] = data
|
|
||||||
}
|
|
||||||
this.data = data
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 第一次进入或从其他组件对应路由进入时触发
|
|
||||||
beforeRouteEnter (to, from, next) {
|
|
||||||
const id = to.params.id
|
|
||||||
if (id) {
|
|
||||||
next(instance => instance.switchData(id))
|
|
||||||
} else {
|
|
||||||
next(new Error('未指定ID'))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 在同一组件对应的多个路由间切换时触发
|
|
||||||
beforeRouteUpdate (to, from, next) {
|
|
||||||
const id = to.params.id
|
|
||||||
if (id) {
|
|
||||||
this.switchData(id)
|
|
||||||
next()
|
|
||||||
} else {
|
|
||||||
next(new Error('未指定ID'))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
export default {
|
export default {
|
||||||
beforeRouteEnter (to, from, next) {
|
beforeRouteEnter (to, from, next) {
|
||||||
next(instance => instance.$router.replace(from.fullPath))
|
from.meta[from.path] = Date.now()
|
||||||
|
next(instance => instance.$router.replace({ path: from.fullPath, meta: from.meta }))
|
||||||
},
|
},
|
||||||
render: h => h()
|
render: h => h()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user