最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue2使用cube-ui?實(shí)現(xiàn)搜索過濾、高亮功能

 更新時(shí)間:2023年01月07日 11:50:05   作者:貝塔-突突  
cube-ui?是基于?Vue.js?實(shí)現(xiàn)的精致移動(dòng)端組件庫,由于很長一段時(shí)間沒有學(xué)習(xí)cube-ui?的功能實(shí)現(xiàn)示例代碼了,今天通過本文給大家介紹下Vue2使用cube-ui?實(shí)現(xiàn)搜索過濾、高亮功能,感興趣的朋友跟隨小編一起看看吧

介紹

cube-ui 是基于 Vue.js 實(shí)現(xiàn)的精致移動(dòng)端組件庫。

特性

  • 質(zhì)量可靠由滴滴內(nèi)部組件庫精簡提煉而來,經(jīng)歷了業(yè)務(wù)一年多的考驗(yàn),并且每個(gè)組件都有充分單元測試,為后續(xù)集成提供保障。
  • 體驗(yàn)極致以迅速響應(yīng)、動(dòng)畫流暢、接近原生為目標(biāo),在交互體驗(yàn)方面追求極致。
  • 標(biāo)準(zhǔn)規(guī)范遵循統(tǒng)一的設(shè)計(jì)交互標(biāo)準(zhǔn),高度還原設(shè)計(jì)效果;接口標(biāo)準(zhǔn)化,統(tǒng)一規(guī)范使用方式,開發(fā)更加簡單高效。
  • 擴(kuò)展性強(qiáng)支持按需引入和后編譯,輕量靈活;擴(kuò)展性強(qiáng),可以方便地基于現(xiàn)有組件實(shí)現(xiàn)二次開發(fā)。

前言

蠻久沒更新 cube-ui 的功能實(shí)現(xiàn)了,公司要為售后部門做一個(gè)方便查看公司產(chǎn)品的一個(gè)項(xiàng)目,遇這需求,雖然常見但自己沒做過,在此做個(gè)例子當(dāng)做記錄。

一、需求

流程:

在這里插入圖片描述

實(shí)現(xiàn)效果:

功能實(shí)現(xiàn)

html

<template>
  <div class = "device-list-main">
    <div class ="header">
      <div class="header_title">
        <cube-select v-model="selectValue" :options="selectOptions" ></cube-select>
      </div>
      <div class="header_input">
        <cube-input v-model="searchValue" placeholder="請(qǐng)輸入搜索值"
        :maxlength=30
        @input='showUpdatePropsPicker'></cube-input>
        <div class="header_input_btn">
          <img :src="searchImgUrl" />
        </div>
      </div>
    </div>
  </div>  
</template>

js

<script>
import searchImgUrl from '@/../static/img/search.png'
export default {
  name: 'DeviceSwitchList',
  data () {
    return {
      searchImgUrl: searchImgUrl,
      selectOptions: ['設(shè)備IMEI', '醫(yī)院名稱'],
      selectValue: '',
      searchValue: '',
      titleName: '設(shè)備設(shè)置',
      data: [{ text: 'R1210699001', value: 'R1210699001' }, { text: 'N1220203010', value: 'N1220203010' },
        { text: 'N1220203001', value: 'N1220203001' }, { text: 'N1220203002', value: 'N1220203002' },
        { text: 'R1220101005', value: 'R1220101005' }]
    }
  },
  methods: {
    showUpdatePropsPicker () {
      var searchValueList = this.searchFilter(this.searchValue)
      if (!this.updatePropsPicker) {
        // 創(chuàng)建一個(gè)選擇器
        this.updatePropsPicker = this.$createPicker({
          title: 'IMEI選擇器',
          data: [searchValueList],
          onSelect: this.selectHandle,
          onCancel: this.cancelHandle
        })
      }
      // 展示
      this.updatePropsPicker.show()
      // 定時(shí)刷新
      setTimeout(() => {
        this.updatePropsPicker.$updateProps({
          data: [searchValueList]
        })
      }, 100)
    },
    // 確認(rèn)后
    selectHandle (selectedVal, selectedIndex, selectedText) {
      if (selectedVal !== '') {
        this.searchValue = selectedVal[0].value
      }
    },
    // 取消后
    cancelHandle () {
    },
    // 篩選(重點(diǎn))
    searchFilter (searchValue) {
      var searchValueList = []
      if (searchValue !== '' || searchValue !== null) {
        if (this.data !== [] || this.data.length > 0) {
          for (let index = 0; index < this.data.length; index++) {
            if (this.data[index].value.search(searchValue) !== -1) {
              var highlight = `<span style="color: #fe7d2d;">${searchValue}</span>`
              searchValueList.push({text: this.data[index].value.replace(searchValue, highlight), value: this.data[index]})
            }
          }
        }
      }
      return searchValueList
    }
  }
}
</script>

css

<style scoped>
.device-list-main {
  height: 100%;
}
/* 頭部樣式 */
.header {
  width: 100%;
  background: #fff;
  padding:  0;
  display: flex;
}
.header_title {
  width: 30%;
  float: left;
}
.cube-select {
  padding: 0;
  line-height: 2rem;
  margin: 0.3rem;
  font-size: small;
}
.cube-input {
  float: left;
  padding: 0;
  font-size: small;
  line-height: 0rem;
  margin-top: 0.3rem;
  width: 82%;
  height: 2rem;
}
.cube-input::after {
  border-radius: 1rem 0 0 1rem;
}
.header_input {
  float: left;
  width: 70%;
}
.header_input_btn {
  float: left;
  background-color: #eee;
  width: 15%;
  border-radius: 0 0.5rem 0.5rem 0;
  margin-top: 0.3rem;
  height: 2rem;
}
.header_input_btn img {
  margin: 0.5rem;
  height: 50%;
}
/* 設(shè)置搜索字體高亮 */
.highlight {
  color: #fe7d2d;
}
.cube-popup-mask {
  display: none;
  overflow: hidden;
  opacity: 0.4;
  pointer-events: auto;
}
</style>

總結(jié)

這只是簡單的一種,還有很多種方法,這是在考慮數(shù)據(jù)量不大的情況下使用,如果數(shù)據(jù)量非常大,可以采用 Spring Boot集成elasticsearch 的方式。有幸做過在這也不好解釋。

到此這篇關(guān)于Vue2使用cube-ui 實(shí)現(xiàn)搜索過濾、高亮功能的文章就介紹到這了,更多相關(guān)vue搜索過濾高亮內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

长寿区| 抚松县| 图片| 陆川县| 开封市| 武威市| 涟水县| 湟源县| 南和县| 镇赉县| 大同市| 田林县| 土默特左旗| 祥云县| 拜泉县| 旌德县| 阳城县| 乐平市| 英吉沙县| 西华县| 红桥区| 彭阳县| 江口县| 泸州市| 丰宁| 乐清市| 股票| 淮阳县| 元谋县| 宁化县| 油尖旺区| 邵东县| 黑河市| 澎湖县| 蒲城县| 澳门| 浦北县| 广元市| 游戏| 余姚市| 酒泉市|