vue中的filters使用data中的数据会报错。上网查了下,在vue的filters中使用this引用data中的数据是无法获取的。因为filters中的this指的并非vue的实例。但通过一下方法可以使用。

在对应的组件中申明全局变量

filters获取data中的数据

在beforeCreated申明周期中修改this的指向,并在filters中使用。就可以获取data中申明的options数组的值

filters获取data中的数据

相关文章:

  • 2021-06-19
  • 2021-12-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-19
  • 2021-07-09
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案