Filters in :bind
See original GitHub issueVue 2.0.5
Filters in :bind does not work
<span :title="text | doUppercase">{{ text | doUppercase }}</span>
<span :title="doUppercase(text)">{{ text | doUppercase }}</span>
Working example not using in any binds, but just in plain simple element <span>{{ text | doUppercase }}</span>
Adding filters to a bind via <span :title="text | doUppercase">{{ text | doUppercase }}</span>
Result in a vue.min.js:6ReferenceError: doUppercase is not defined(…)
Also tried adding filters via <span :title="doUppercase(text)">{{ text | doUppercase }}</span>
Result in a vue.min.js:6ReferenceError: doUppercase is not defined(…)
So you can not use filters in :bind?
In the documentation is reads: Vue 2.x filters can only be used inside mustache bindings
Is this a mustache bindings? -
My use case is quite simple
My output would be something like this
Input: <span :title="date | momentFull">{{ date | moment }}</span>
Output: <span title="2016-11-10 08:32">2 hours ago</span>
filters: {
moment (date) {
return Moment(date).fromNow();
},
momentFull (date) {
return Moment(date).format('YYYY-MM-DD HH:mm');
}
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
I don’t think so because it belongs to migration. It’s absent on the Vue 2 docs because it doesn’t exist anymore after all
It looks pretty clear to me: https://vuejs.org/v2/guide/syntax.html#Filters The reason is that bindings’ content is jslike. Filters are a common practice in interpolation