简单业务需求集合

2018年12月12日
暂时把最近项目上写的一些简单需求做个总结
1.搜索框,进行模糊搜索(使用vue实现,vue自定义指令,做函数防抖优化)

<input type="text" v-throttle="search" id="entityId" placeholder="请输入" v-model="company">
directives: {
    // 自定义函数防抖指令
    throttle: {
      inserted (el, binding) {
        let timer
        el.addEventListener('keydown', () => {
          clearTimeout(timer)
          timer = setTimeout(() => {
            binding.value()
          }, 300)
        })
      }
    }
  }
// 模糊查询请求
search () {
  if (this.company.length > 0) {
    searchProperties(this.company, this.graphName)
    .then((res) => {
      this.searchCompanies = []
      for (let key in res) {
        res[key].forEach((val) => {
          if (this.searchCompanies.length < 10) {
            this.searchCompanies.push(val)
          }
          this.isKeyUp = true
        })
      }
    })
  } else {
    this.isKeyUp = false
  }
}

下次再改

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容