防抖節(jié)流使用示例

updateCameraView: debounce((element, map) => {
      const bearing = ((-element.carStateView.carState.rotation.z + Math.PI / 2) / Math.PI) * 180
      map.flyTo({
        center: element.carStateView.carState.arrayPosition.position,
        speed: 1.2,
        zoom: 20,
        essential: true, // 動(dòng)畫(huà)
        duration: 300,
        bearing: bearing
      })
    }, 50),
getList: throttle(function(type) {
      // this.$refs.scenariosTable.clearSelection()
      this.listLoading = true
      if (type !== 'num') {
        this.searchFrom.page_index = 1
      }
      if (this.searchFrom.tagData && this.searchFrom.tagData.length > 0) {
        this.searchFrom.tag = this.searchFrom.tagData.join(';')
      }
      if (this.searchFrom.createDate) {
        this.searchFrom['atime_start'] = this.searchFrom.createDate[0]
        this.searchFrom['atime_end'] = this.searchFrom.createDate[1]
      }
      if (this.searchFrom.updateDate) {
        this.searchFrom['mtime_start'] = this.searchFrom.updateDate[0]
        this.searchFrom['mtime_end'] = this.searchFrom.updateDate[1]
      }
      getSceneManagerRequest(this.searchFrom).then(response => {
        if (response) {
          this.dataList = response.data.scenarios.map((item) => {
            item['scenario_source_name'] = this.sourceArray.filter((source) => source.key === item.scenario_source)[0].value
            item['region_name'] = this.regionArray.filter((source) => source.key === item.region)[0].value
            item['region_property_name'] = this.region_propertyArray.filter((source) => source.key === item.region_property)[0].value
            item['category_name'] = this.categoryArray.filter((source) => source.key === item.category)[0].value
            item['scene_env_name'] = this.envArray.filter((source) => source.key === item.scene_env)[0].value
            const tagList = []
            if (item.tag && item.tag.length > 0) {
              item.tag.split(';').forEach((key) => {
                this.tagArray.forEach(element => {
                  if (element.key === key) {
                    tagList.push(element.value)
                  }
                })
              })
            }
            item['tag_name'] = tagList.join(';')
            return item
          })
          this.total = response.data.total
          this.listLoading = false
        }
      }).catch(() => {
        this.listLoading = false
      })
      const that = this
      setTimeout(() => {
        that.toggleSelection()
      }, 500)
    }, 1000),
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容