vue 过滤器

<template>
  <div>
     {{  time | formatTime }}
    {{ status | getDicVal(statusDic) }}
  </div>
</template>

statusDic: [
{ key: '1', value: '启用' },
{ key: '2', value: '停用' }
]

filters: { formatTime (time) { return time.slice(0, 4) + '-' + time.slice(4, 6) + '-' + time.slice(6, 8) + ' ' + time.slice(9, 17) }, getDicVal: (key, dic) => dic.find(v => v.key === key).value }
原文地址:https://www.cnblogs.com/shine-lovely/p/14171816.html