I know that to use a filter in Vue
, you can make the call as follows:
Vue.filter('hello', function (input) {
return "hello, " + input;
})
new Vue({
el: "#app",
data: {
name: "Wallace",
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js"></script><divid="app">
{{ name | hello }}
</div>
That is, through interpolation, it is possible to call a filter
perfectly.
The problem is when I try to use v-text
. It seems that Vue behaves differently in these cases.
Vue.filter('hello', function (input) {
return "hello, " + input;
})
new Vue({
el: "#app",
data: {
name: "Wallace",
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js"></script><divid="app">
<span v-text="name | hello"></span>
</div>
Note that when you run, an error appears:
hello
is not defined
In this case, I come from AngularJS and I know that it is possible to use filters
with both ng-bind
and interpolation.
But what about Vue
? Why does not it work?
I did not see any details in the documentation regarding this.
Is there any way to circumvent this problem?