解决方法:
1、定义一个变量:
2、在beforeCreate生命周期将this赋值给that,通过that获得
var vm = new Vue({ el: ‘#app‘, data: { }, beforeCreate: function () { that = this }, methods:{ fom(fmt){ ... } }, ...., filters: { dateformate: function (val) { return that.fom("yyyy-MM-dd") } } })
过滤器学习笔记: https://www.cnblogs.com/meiyanstar/p/14759634.html
原文:https://www.cnblogs.com/meiyanstar/p/14763332.html