| | |
| | | watch: { |
| | | show(value) { |
| | | if (value && !this.clickNotClose) { |
| | | this.addEventClick() |
| | | // 延后到本次点击结束后再监听,避免“点开就被同一次点击关掉” |
| | | this.$nextTick(this.addEventClick) |
| | | } else { |
| | | window.removeEventListener('click', this.closeSidebar) |
| | | } |
| | | if (value) { |
| | | addClass(document.body, 'showRightPanel') |
| | |
| | | }, |
| | | mounted() { |
| | | this.insertToBody() |
| | | this.addEventClick() |
| | | }, |
| | | beforeDestroy() { |
| | | window.removeEventListener('click', this.closeSidebar) |
| | | const elx = this.$refs.rightPanel |
| | | elx.remove() |
| | | }, |
| | | methods: { |
| | | addEventClick() { |
| | | // 先移除再添加,避免重复监听 |
| | | window.removeEventListener('click', this.closeSidebar) |
| | | window.addEventListener('click', this.closeSidebar) |
| | | }, |
| | | closeSidebar(evt) { |