过滤器

Vue.filter( id, [definition] )

参数:

{string} id

{Function} [definition]

用法:

注册或获取全局过滤器。

Vue.filter('my-filter', function (value) { // 返回处理后的值 })

例子:

需求:为身份证号出生年月日加***的处理

filters: {
    hideMiddle(val) {
      let strval = val.toString();
      return `${strval.substring(0, 7)}**${strval.substring(
        strval.length - 4
      )}`;
    }
  }

  

原文地址:https://www.cnblogs.com/ray123/p/11983805.html