栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

解决虚拟渲染大数据表格无法使用ctrl+f搜索,自己模拟一个

解决虚拟渲染大数据表格无法使用ctrl+f搜索,自己模拟一个

⚠️⚠️⚠️⚠️⚠️⚠️注意。mac、win、上面监听按键是有差异的,比如(e.key === ‘meta’) || (e.key === ‘Control’),谷歌浏览器和qq浏览器、edge浏览器也有差异e.key === ‘f’ || e.key === ‘F’。,大小写
created() {
    window.addEventListener('keydown', this.keydown)
    window.addEventListener('keyup', this.keyup)
    // 监听双击事件
    window.addEventListener('dblclick', this.doubleClick)
  },


methods: {
	keydown(e) {
      if (ROUTER_PATH.includes(this.$route.path)) {
        if ((e.key === 'meta') || (e.key === 'Control')) this.CONTROL = 1
        if (e.key === 'f' || e.key === 'F') this.F = 1
        console.log(this.CONTROL, this.F, 'sss')
        if (this.CONTROL === 1 && this.F === 1) {
          this.ctrlf = true
          // this.ctrlf = !this.ctrlf
          // 关闭搜索时 返回表格全部数据
          if (this.ctrlf) {
            this.doubleClick()
            this.searchBill()
          } else {
            this.searchName = ''
          }
          e.preventDefault()
        }
      } else {
        window.removeEventListener('keydown', this.keydown, true)
      }
    },
    keyup(e) {
      if (ROUTER_PATH.includes(this.$route.path)) {
        // mac 和 windows有区别
        const isMac = /macintosh|mac os x/i.test(navigator.userAgent)
        if (isMac) {
          this.CONTROL = 0
          this.F = 0
        } else {
          if (e.key === 'Control') this.CONTROL = 0
          if (e.key === 'f') this.F = 0
        }
      } else {
        window.removeEventListener('keyup', this.keyup, true)
      }
    },
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/688244.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号