npm install xe-utils vxe-utils --save
通过 Vue.use() 来全局安装
import Vue from 'vue'
import XEUtils from 'xe-utils'
import VXEUtils from 'vxe-utils'
// mounts 可以设置['cookie', 'browse', 'locat']
Vue.use(VXEUtils, XEUtils, {mounts: ['cookie']})
使用
<template>
<div>{{ $utils.toDateString(startDate, 'yyyy-dd-MM HH:mm:ss') }}</div>
<div>{{ endDate }}</div>
</template>
<script>
export default {
name: 'App',
data: {
return {
startDate: new Date(),
endDate: null
}
},
created () {
this.endDate = this.$utils.toDateString(new Date(), 'MM/dd/yyyy HH:mm:ss.SSS')
}
}
</script>