| 123456789101112131415161718192021222324 |
- // 全局引入 (main.js)
-
- import Vue from 'vue'
- import moment from 'moment'
- import { cutStrByFullLength, getStrFullLength } from '@/utils/utils'
- // 全局过滤器 时间戳
- Vue.filter('dateformat', function (dataStr, pattern = 'YYYY-MM-DD') {
- if (dataStr) {
- return moment(dataStr).format(pattern)
- } else {
- return dataStr
- }
- })
- // 全局过滤器 过滤文字
- Vue.filter('ellipsis', function (str, maxLength) {
- if (str) {
- const fullLength = getStrFullLength(str);
- return cutStrByFullLength(str, maxLength)+(fullLength > maxLength ? '...' : '');
- } else {
- return str
- }
- })
|