How to call the method method in filter in vue component

how does the following filters call padDate in method and pass a value?
filters: {

    formatDate: function(value) {
        let _this = this;
        let date = new Date(value);
        let year = date.getFullYear();
        let month = padDate(date.getMonth()+1);
        let day = padDate(date.getDate());
        let hour = padDate(date.getHours());
        let minutes = padDate(date.getMinutes());
        let seconds = padDate(date.getSeconds());
        return year +"-"+month +"-"+day+""+hour+":"+minutes+":"+seconds;
    }

},
methods: {

  padDate(value){
      return value <10?"0"+value :value;
  }

}

Apr.09,2021

this.padDate (xx) access


what to do at last


when writing functions, use formatDate: (vaule) = > {/ * code*/} to pass this, and then use this.padDate (v) should be feasible


filters this is window, The context is not vue


var _ this = window.vm


{{ this | filterMsg}
passes this into filter as a parameter, so you can access the methods defined in methods.


is written directly in methods, how about calling it directly in the view?

methods: {
    formatDate(value){
        padDate(value)
    }
<view>{{formate(date)}}</view>
Menu