vue过滤器filters获取不到this对象的解决办法
<template> <div>{{a|sum(that)}}</div> </template> <script> export default { name: "test", data() { return { that: this, a: 1, b: 2 } }, filters: { sum(a, that) { console.log(that); return a + that.b; } }, }
<template> <div>{{a|sum(that)}}</div> </template> <script> export default { name: "test", data() { return { that: this, a: 1, b: 2 } }, filters: { sum(a, that) { console.log(that); return a + that.b; } }, }