首页
vue中filters使用data或异步数据
filter中的this是全局的不是指向的vue实例,那么也就不能使用
this.xxx
解决的方法
首先定义一个全局的变量
然后在vue创建前的生命周期钩子函数中将that指向this
beforeCreate () { that = this }
然后就可以在filter中通过that访问vue实例了
工作随笔
相关
工作随笔
工作随笔
标签