vue3版本初版上线 自测已可用
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
<div class="router-history">
|
||||
<el-tabs
|
||||
v-model="activeValue"
|
||||
:closable="!(historys.length===1&&this.$route.name===defaultRouter)"
|
||||
:closable="!(historys.length===1&&$route.name===defaultRouter)"
|
||||
type="card"
|
||||
@contextmenu.prevent.native="openContextMenu($event)"
|
||||
@contextmenu.prevent="openContextMenu($event)"
|
||||
@tab-click="changeTab"
|
||||
@tab-remove="removeTab"
|
||||
>
|
||||
@@ -16,7 +16,9 @@
|
||||
:tab="item"
|
||||
class="gva-tab"
|
||||
>
|
||||
<span slot="label" :style="{color: activeValue===name(item)?activeColor:'#333'}"><i class="dot" :style="{backgroundColor:activeValue===name(item)?activeColor:'#ddd'}" /> {{ item.meta.title }}</span>
|
||||
<template #label>
|
||||
<span :style="{color: activeValue===name(item)?activeColor:'#333'}"><i class="dot" :style="{backgroundColor:activeValue===name(item)?activeColor:'#ddd'}" /> {{ item.meta.title }}</span>
|
||||
</template>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
@@ -32,6 +34,8 @@
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
import { emitter } from '@/utils/bus.js'
|
||||
|
||||
const getFmtString = (item) => {
|
||||
return item.name +
|
||||
JSON.stringify(item.query) +
|
||||
@@ -75,15 +79,15 @@ export default {
|
||||
sessionStorage.setItem('historys', JSON.stringify(this.historys))
|
||||
this.activeValue = window.sessionStorage.getItem('activeValue')
|
||||
if (now && to && now.name === to.name) {
|
||||
this.$bus.$emit('reload')
|
||||
emitter.emit('reload')
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$bus.on('mobile', isMobile => {
|
||||
emitter.on('mobile', isMobile => {
|
||||
this.isMobile = isMobile
|
||||
})
|
||||
this.$bus.on('collapse', isCollapse => {
|
||||
emitter.on('collapse', isCollapse => {
|
||||
this.isCollapse = isCollapse
|
||||
})
|
||||
const initHistorys = [
|
||||
@@ -107,8 +111,8 @@ export default {
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
this.$bus.off('collapse')
|
||||
this.$bus.off('mobile')
|
||||
emitter.off('collapse')
|
||||
emitter.off('mobile')
|
||||
},
|
||||
methods: {
|
||||
name(item) {
|
||||
@@ -120,7 +124,6 @@ export default {
|
||||
}
|
||||
let id = ''
|
||||
if (e.srcElement.nodeName === 'SPAN') {
|
||||
console.log(e)
|
||||
id = e.srcElement.offsetParent.id
|
||||
} else {
|
||||
id = e.srcElement.id
|
||||
@@ -236,7 +239,7 @@ export default {
|
||||
)
|
||||
},
|
||||
changeTab(component) {
|
||||
const tab = component.$attrs.tab
|
||||
const tab = component.instance.attrs.tab
|
||||
this.$router.push({
|
||||
name: tab.name,
|
||||
query: tab.query,
|
||||
|
||||
Reference in New Issue
Block a user