So I'm trying to implement the functionality explained here Vuejs Search filter but the function inside the computed doesn't seem to work, not even logging anything, here's my code:
...
<a-layout-header style="background: #fff; padding: 0">
<a-input-search
placeholder="Search everything"
style="width: 200px; marginLeft: 20px"
v-model="searchData"
/>
<a-button type="primary" style="marginLeft: 20px">
+ New
</a-button>
</a-layout-header>
...
data() {
return {
data: json,
collapsed: false,
item_key: 1,
searchData: ''
};
},
computed: {
searchResult() {
if (this.searchData) {
return this.data.filter((item) => {
return this.searchData.toLowerCase().split(' ').every(v =>
item.title.toLowerCase().includes(v));
})
} else {
return this.data;
}
}
},
Edit: the data that is filtering it's being passed as a prop to a child component, and there I have a ant-design table that gets it:
<a-table
v-if="this.item.toString() === '1'"
:columns="columns"
:row-key="record => record.guid"
:data-source="normalData"
:pagination="pagination"
:row-selection="rowSelection"
>
</a-table>
{{ searchResult }}somewhere in your template to see what's the value computed! Or you can use the chrome "vuejs devtools" extension to debug your Vuejs app