Решил взять
здесь код для поиска во VueJS 2.0
Однако при поиске выдает ошибку:
vue.min.js:6 TypeError: Cannot read property 'toString' of null
at Object.values.some.m (home.js:281)
at Array.some (<anonymous>)
at sortedTokens_VMP.filter.n (home.js:281)
at Array.filter (<anonymous>)
at a.filteredTokens_VMP (home.js:281)
at Kr.get (vue.min.js:6)
at Kr.evaluate (vue.min.js:6)
at a.filteredTokens_VMP (vue.min.js:6)
at a.eval (eval at Tn (vue.min.js:6), <anonymous>:3:4728)
at a.t._render (vue.min.js:6)
Как выглядит код:
computed: {
sortedTokens_VMP() {
const k = this.sortKey
return this.tokens_VMP.sort((a, b) => (a[k] < b[k] ? -1 : a[k] > b[k] ? 1 : 0) * [1, -1][+this.reverse])
},
filteredTokens_VMP() {
const s = this.search.toLowerCase()
return this.sortedTokens_VMP.filter(n => Object.values(n).some(m => m.toString().toLowerCase().includes(s)))
}
},
methods: {
sortBy: function (sortKey) {
this.reverse = (this.sortKey == sortKey) ? !this.reverse : false;
this.sortKey = sortKey;
},
},
Чисто поменял переменные.
Сам объект:
number_token:(...)
patient: {last_name: 'test', first_name: 'test'}
place_residence:(...)
profile:(...)
recourse:(...)
result_hospitalization:(...)
short_name_MO:(...)
social_group:(...)
stage:(...)
subject_RF:(...)
treatment_method:(...)
view_appeal:(...)
view_extract:(...)