关闭el-date-picker时间选择

关闭 el-date-picker 时间选择功能

问题:下拉滚动条,el-date-picker 还是展开状态
期望:下拉滚顶条让 el-date-picker 关闭。

解决方案:监控滚动高度,当滚动条高度大于 0,调用 this.$refs.时间插件命名.hidePicker()

mounted(){
     window.addEventListener('scroll', this.handleScroll, true)
}
methods:{
     handleScroll() {
      let dom = document.querySelector('.overflowBox')
      this.$nextTick(() => {
        this.scrollTop = dom.scrollTop
      })
    }
}
watch:{
    scrollTop(newVal, oldVal) {
      if (newVal > 0) {
        this.$refs.datePicker.hidePicker()
      }
    },

}
posted @ 2022-11-08 16:02  崛起崛起  阅读(896)  评论(0)    收藏  举报