【study】判断除了这个弹窗之外,点击任意一个地方,这个弹窗都关闭

110 阅读1分钟
  mounted () {
    let _this = this
    document.addEventListener('click', (e) => {
      _this.$nextTick(() => {
        //获取弹窗的ref
        let contentMore = this.$refs.contentMore
        if (contentMore) {
          if (!contentMore.contains(e.target)) {
          //控制显示还是隐藏
            this.moreDialog = true
          } else {
            this.moreDialog = false
          }
        }
      })
    })
  }