Browse Source

新增全局关闭当前页面函数

main
范庆磊 3 years ago
parent
commit
664bf9149a
  1. 11
      web/src/view/layout/aside/historyComponent/history.vue
  2. 2
      web/src/view/layout/index.vue

11
web/src/view/layout/aside/historyComponent/history.vue

@ -16,7 +16,7 @@
:tab="item" :tab="item"
class="gva-tab" 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>
<span slot="label" :style="{color: activeValue===name(item)?activeColor:'#333'}"><i class="dot" :style="{ backgroundColor:activeValue===name(item)?activeColor:'#ddd'}" /> {{ item.meta.title }}</span>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
@ -105,7 +105,13 @@ export default {
} }
this.setTab(this.$route) this.setTab(this.$route)
}, },
mounted(){
//
this.$bus.on('closeThisPage', ()=>{
const router = this.$route.path.split("/")
this.removeTab(`${router[router.length - 1]}`)
})
},
beforeDestroy() { beforeDestroy() {
this.$bus.off('collapse') this.$bus.off('collapse')
this.$bus.off('mobile') this.$bus.off('mobile')
@ -244,6 +250,7 @@ export default {
}) })
}, },
removeTab(tab) { removeTab(tab) {
console.log(tab)
const index = this.historys.findIndex( const index = this.historys.findIndex(
item => getFmtString(item) === tab item => getFmtString(item) === tab
) )

2
web/src/view/layout/index.vue

@ -68,7 +68,7 @@
<!-- 当前面包屑用路由自动生成可根据需求修改 --> <!-- 当前面包屑用路由自动生成可根据需求修改 -->
<!-- <!--
:to="{ path: item.path }" 暂时注释不用--> :to="{ path: item.path }" 暂时注释不用-->
<HistoryComponent />
<HistoryComponent ref="layoutHistoryComponent" />
</div> </div>
</transition> </transition>
<transition mode="out-in" name="el-fade-in-linear"> <transition mode="out-in" name="el-fade-in-linear">

Loading…
Cancel
Save