无法在 Vue 组件过滤器中访问 "this"

Cannot access "this" in Vue compnent filter

过滤器在组件选项中定义如下:

Vue.extend({
  ...
  props: ['filterFn', ......],

  filters: {
    myFilter(value){
      return this.filterFn ? this.filterFn(value) : value;
    }
  },

  ...
});

它使用一个作为 属性 传递给组件的函数。

但是不行。

它告诉我它无法读取未定义的 属性 filterFn...

过滤器未绑定到组件实例。 请改用方法。

https://forum.vuejs.org/t/why-does-this-inside-a-filter-function-is-undefined/18321 https://github.com/vuejs/vue/issues/5998