vue-filter

Filter Vue list based on select option value

混江龙づ霸主 提交于 2020-06-29 06:41:06
问题 I try to filter my list with 2 select lists based on the selected value. It seems like my computed filter is not working? You should be able to filter the list on 'Price from' and 'Price to' List.vue My computed filter property: filteredData() { const LowerCaseSearch = this.search.toLowerCase(); return this.products.filter( product => (product.name.toLowerCase().includes(LowerCaseSearch) || product.category.toLowerCase().includes(LowerCaseSearch)) && (!this.checked.length || this.checked

Use filter inside v-for

人盡茶涼 提交于 2020-04-14 06:57:31
问题 I have a simple Vue filter that limits the length of an array to n elements. It works fine used like this: {{ array | limitArray(2) }} Now I'd like to use it inside a v-for loop, like this: <li v-for="item in items | limitArray(3)">...</li> But that throws errors. How can I use a filter inside a v-for ? Edit: Probably unimportant, but the filter in question: Vue.filter('limitArray', function (arr, length = 3) { if (arr && arr.length) { if (length == -1) { return arr; } if (length > arr.length