Closed
Description
<template>
<router-tab />
</template>
<script>
export default {
mounted() {
document.addEventListener('mousedown', this.middleClick)
},
destroyed() {
document.removeEventListener('mousedown', this.middleClick)
},
methods: {
middleClick(e) {
if (e && (e.which == 2 || e.button == 4) && /router-tab__item/.test(e.target.className)) {
const to = e.target.closest('.router-tab__item').__vue__.to,
closable = this.$tabs.items.reduce((r, item) => ({ ...r, [item.to]: (item.closable ??= true) }), {})
if (closable[to]) this.$tabs.close(to)
}
}
}
}
</script>