<div class="fl w-200 m-l-30">
<el-input placeholder="輸入用戶名" v-model="searchData">
<el-button slot="append" icon="el-icon-search" @click="search()">搜索</el-button>
</el-input>
</div>
--------------------------------
export default {
data() {
return {
tableData: [],
dataCount: null,
currentPage: null,
realname: '',
multipleSelection: [],
page_size:7,
currentpagezyt:1,
list:[],
total:null, //和:total對應
searchData: "",
}
},
methods: {
search() {
this.page=1;
this.getList();
},
-------------------------
//處理數據
getList() {
//es6過濾得到滿足搜索條件的展示數據list
let list = this.tableData.filter((item, index) =>
item.userName.includes(this.searchData)
)//取每一個item,看看item的userName屬性equal(input內的searchData)
this.list = list.filter((item, index) =>
index < this.page * this.limit && index >= this.limit * (this.page - 1)
)
this.total = list.length
},