Commit a9e5710a by kokoroli

fix:MultiTab close methods

parent bbd917d4
...@@ -49,8 +49,10 @@ export default { ...@@ -49,8 +49,10 @@ export default {
remove (targetKey) { remove (targetKey) {
this.pages = this.pages.filter(page => page.fullPath !== targetKey) this.pages = this.pages.filter(page => page.fullPath !== targetKey)
this.fullPathList = this.fullPathList.filter(path => path !== targetKey) this.fullPathList = this.fullPathList.filter(path => path !== targetKey)
// 跳转到最后一个还存在的标签页 // 判断当前标签是否关闭,若关闭则跳转到最后一个还存在的标签页
if (!this.fullPathList.includes(this.activeKey)) {
this.selectedLastPath() this.selectedLastPath()
}
}, },
selectedLastPath () { selectedLastPath () {
this.activeKey = this.fullPathList[this.fullPathList.length - 1] this.activeKey = this.fullPathList[this.fullPathList.length - 1]
...@@ -65,15 +67,29 @@ export default { ...@@ -65,15 +67,29 @@ export default {
// TODO // TODO
console.log('close left', e) console.log('close left', e)
const index = this.fullPathList.indexOf(e) const index = this.fullPathList.indexOf(e)
if (index > -1) { if (index > 0) {
this.fullPathList.splice(index, -1) this.remove(this.fullPathList[index - 1])
} else {
this.$message.info('左侧没有标签')
} }
}, },
closeRight (e) { closeRight (e) {
console.log('close right', e) console.log('close right', e)
const index = this.fullPathList.indexOf(e)
if (index < (this.fullPathList.length - 1)) {
this.remove(this.fullPathList[index + 1])
} else {
this.$message.info('右侧没有标签')
}
}, },
closeAll (e) { closeAll (e) {
console.log('close all', e) console.log('close all', e)
const currentIndex = this.fullPathList.indexOf(e)
this.fullPathList.forEach((item, index) => {
if (index !== currentIndex) {
this.remove(item)
}
})
}, },
closeMenuClick ({ key, item, domEvent }) { closeMenuClick ({ key, item, domEvent }) {
console.log('key', key) console.log('key', key)
...@@ -132,7 +148,13 @@ export default { ...@@ -132,7 +148,13 @@ export default {
render () { render () {
const { onEdit, $data: { pages } } = this const { onEdit, $data: { pages } } = this
const panes = pages.map(page => { const panes = pages.map(page => {
return (<a-tab-pane style={{ height: 0 }} tab={this.renderTabPane(page.meta.title, page.fullPath)} key={page.fullPath} closable={pages.length > 1}></a-tab-pane>) return (
<a-tab-pane
style={{ height: 0 }}
tab={this.renderTabPane(page.meta.title, page.fullPath)}
key={page.fullPath} closable={pages.length > 1}
>
</a-tab-pane>)
}) })
return ( return (
......
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