日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > vue >内容正文

vue

antvue table 表格实现 首行搜索

發布時間:2023/12/29 vue 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 antvue table 表格实现 首行搜索 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

antvue table 表格實現 首行搜索

首先創建一個組件用來渲染 頭部輸入框

<template><div class="filter"><tr><th><div class="selectDiv"></div></th><th v-for="(item, index) in columns" :key="index"><div class="selectDiv" :style="'width:' + item.width + 'px'"><a-inputstyle=" text-align: inherit; min-width: 150px;"v-if="index >= deviationNumber":placeholder="'請輸入' + item.title"v-model="item.filter"@change="onSearch(item)"/></div></th></tr></div> </template> <script> export default {data() {return {value: '',}},props: {columns: {type: Array,},deviationNumber:{type: Number,default:2,}},methods: {select() {console.log(this.columns)},onSearch(item) {// console.log(item);this.$emit('onSearch', item)},}, } </script>

接著在 ant vue table 頁面引用該 組件,并傳入表頭columns [ ] 數據集合(具體用法參閱官方文檔)

columns 集合實例:

columns: [{title: '操作',dataIndex: 'action',align: 'center',// fixed: 'right',width: 147,scopedSlots: { customRender: 'action' },},{title: '名稱',align: 'center',dataIndex: 'name',},],

組件使用示例

<filterth ref="filterth" @onSearch="onSearchFilter" :deviationNumber="1" :columns="columns"></filterth>

接著在使用該組件 的頁面 mounted函數里渲染組件至 表格頭部

mounted() {this.$nextTick(() => {this.$refs.table.$el.getElementsByTagName('thead')[0].appendChild(this.$refs.filterth.$el.getElementsByTagName('tr')[0])})},

onSearchFilter 方法

主要 實現輸入框值的獲取 和查詢
具體根據自己業務實際情況編寫 以下 僅供參考

onSearchFilter(item) {if (item.filter == undefined) {return}// console.log( this.queryParamData )let name = item.dataIndexthis.$set(this.queryParam, name, `*${item.filter}*`)//刷新列表數據的函數this.searchQuery()},

總結

以上是生活随笔為你收集整理的antvue table 表格实现 首行搜索的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。