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

vue3中element-plus表格搜索過濾數(shù)據(jù)

 更新時(shí)間:2025年03月26日 08:58:22   作者:BillKu  
本文主要介紹了vue3中element-plus表格搜索過濾數(shù)據(jù),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

1、表格數(shù)據(jù)

// 表格數(shù)據(jù)
import type { User } from "@/interface";
const tableData = ref<User[]>([]);

2、 表格搜索過濾數(shù)據(jù)

// 搜索內(nèi)容
const search = ref("");
// 表格過濾數(shù)據(jù)
const tableFilterData = computed(() =>
  tableData.value.filter(
    (data) => !search.value || data.moniker?.includes(search.value)
  )
);
// 表格過濾數(shù)據(jù),等價(jià)代碼(分步拆解)
/*
const tableFilterData = computed(() => {
  // 若 search 為空,直接返回原數(shù)組
  if (search.value) return tableData.value;

  // 否則過濾包含關(guān)鍵詞的項(xiàng)
  return tableData.value.filter((data) => {
    // 安全訪問 moniker,不存在則返回 undefined(過濾掉)
    let moniker = data.moniker ?? "";
    return moniker.includes(search.value);
  });
});
*/

3、表格引用搜索過濾數(shù)據(jù),:data="tableFilterData"

<el-table
  :data="tableFilterData"
  <el-table-column type="selection" header-align="center" />
  <el-table-column prop="moniker" label="人員">
    <template #header>
      <el-input v-model="search" :prefix-icon="Search">
        <template #prepend>人員</template>
      </el-input>
    </template>
  </el-table-column>
</el-table>

4、應(yīng)用效果

 

到此這篇關(guān)于vue3中element-plus表格搜索過濾數(shù)據(jù)的文章就介紹到這了,更多相關(guān)element-plus表格過濾內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

城市| 建平县| 哈巴河县| 兴化市| 泗水县| 清流县| 离岛区| 唐山市| 湘乡市| 新化县| 财经| 六枝特区| 射洪县| 台南市| 宜昌市| 仙桃市| 林甸县| 汾西县| 错那县| 建阳市| 通榆县| 鄢陵县| 宣城市| 广平县| 绥棱县| 烟台市| 中阳县| 舟山市| 竹山县| 张家界市| 马山县| 梅河口市| 宣城市| 乐陵市| 巴马| 玉环县| 广德县| 宣城市| 马关县| 花莲市| 延吉市|