sinake
6 小时以前 2016aa7a49026fc6ead02604200889a653ad6cdc
src/components/RightPanel/index.vue
@@ -43,7 +43,10 @@
  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')
@@ -54,14 +57,16 @@
  },
  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) {