Answer the question
In order to leave comments, you need to log in
How to write custom filters in vue js?
Interested in how to write your own filter in vue. I found on the net where native view filters are shown, and those who themselves wrote for some reason do not work.
For example, a simple word replacement function.
I did it in two ways but gives an error that they are doing it wrong.
filter: {
vend: function(item){
return item.replace("17", "RTX3");
}
},
Vue.filter('vend',function(item){
return item.replace("17", "RTX3");
})
<tr v-for="item in selected">
<td>${item.vendor | vend }</td>
</tr>
Answer the question
In order to leave comments, you need to log in
it seems, everything works, only you need to use {{}} https://jsfiddle.net/pwrzkg1o/1/
Well, in general, the value of filters in this context is doubtful, I would use calculated properties.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question