Vue之在methods中使用filter的方法

2018-12-18  本文已影响6人  studentliubo

1、filter有两种方式

设置全局的filter的方法

  Vue.filter(‘name’,function (val) {})

设置当前组件的方法

 filter: {
  functionName (val) {
  // logic process
  }
}

2、如果想在methods中使用filters的方法,相应的就有两种方法

使用全局的filter: Vue.filters['filterName'] (val)
使用局部的filter: this.$options.filters['filterName'] (val)

上一篇 下一篇

猜你喜欢

热点阅读