1、结构

<template>
  <div class="Ling">
    <input type="text" v-model="searchValue" />
    <div v-for="(item, index) in personInfoListSearch" :key="index">
      {{ item.personIdAndName }}
    </div>
  </div>
</template>

2、数据

  data() {
    return {
      // 查询值
      searchValue: "",
      personInfo: [
        {
          personId: "gailun",
          personIdAndName: "(gailun)盖伦",
          personName: "盖伦"
        },
        {
          personId: "aobama",
          personIdAndName: "(aobama)奥巴马",
          personName: "奥巴马"
        },
        {
          personId: "psmart",
          personIdAndName: "(psmart)ps",
          personName: "ps"
        }
      ]
    };
  },

3、计算属性

  computed: {
    //   人员查询
    personInfoListSearch() {
      return this.personInfo.filter(o => {
        return (
          o.personId.indexOf(this.searchValue) > -1 ||
          o.personName.indexOf(this.searchValue) > -1
        );
      });
    }
  }

4、例1

5、例2

6、例3

posted on 2022-01-21 13:29  丶凉雨拾忆  阅读(254)  评论(0编辑  收藏  举报