vue 关闭当前tab页,并更新父组件数据
export default {
data () {
return {
componentKey: 0
}
}
},
methods: {
onSubmit() {
let tabName = this.$store.state.contentTabsActiveName
this.$store.state.contentTabs = this.$store.state.contentTabs.filter(item => item.name !== tabName)
if (this.$store.state.contentTabs.length <= 0) {
this.$store.state.sidebarMenuActiveName = this.$store.state.contentTabsActiveName = 'home'
return false
}
let tab = this.$store.state.contentTabs[this.$store.state.contentTabs.length - 1]
this.$router.push({
name: tab.name,
params: { ...tab.params },
query: { ...tab.query }
})
this.componentKey += 1;
}
}