nuxt.config.js
plugins: [
'~/plugins/router.js',
// 配置拦截器
{
src: '~/plugins/axios',
ssr: true // 开启服务端渲染
},
{
src: '~/plugins/element-ui',
ssr: true, //不支持服务端渲染不要给true
// mode: 'server' // 模式服务端
},
'~/plugins/global'
],
global.js
import Vue from 'vue'
import * as filters from '../assets/script/filter'
Object.keys(filters).forEach(key => Vue.filter(key, filters[key]))
filter
export const makeUpZero = (num) => {
return num < 10 && '0' + num || num + ''
}
export const formatDate = (time) => {
let _d = new Date()
_d.setTime(time)
let year = _d.getFullYear()
let month = _d.getMonth() + 1
let date = _d.getDate()
let hour = _d.getHours()
let min = _d.getMinutes()
let sec = _d.getSeconds()
return `${year}年${makeUpZero(month)}月${makeUpZero(date)}日 ${makeUpZero(hour)}:${makeUpZero(min)}:${makeUpZero(sec)}`
}
网友评论