In Vue JS, call a filter from a method inside the vue instance

后端 未结 5 1686
自闭症患者
自闭症患者 2020-12-23 14:24

Say I have a Vue instance like so:

new Vue({
    el: \'#app\',

    data: {
        word: \'foo\',
    },

    filters: {
       capitalize: function(text) {         


        
5条回答
  •  伪装坚强ぢ
    2020-12-23 14:52

    if your filter is something like this

    {{ count }} {{ 'item' | plural(count, 'items') }}  
    

    this is the answer

    this.$options.filters.plural('item', count, 'items')
    

提交回复
热议问题