Moment.js 时间格式化
使用步骤,官网http://momentjs.cn/
npm install moment --save # npm或使用cnpm
简单的案例
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>Document</title>
<script type='text/javascript' src='../js/vue.js'></script>
<script type='text/javascript' src='https://cdn.bootcss.com/moment.js/2.24.0/moment.min.js'></script>
</head>
<body>
<div id='app'>
{{date | aa('YYYY-MM-DD hh:mm:ss')}}
</div>
<script type='text/javascript'>
var vm = new Vue({
el: '#app',
data: {
date:new Date()
},
filters:{
aa(msg,str){
return moment(msg).format(str);
}
}
});
</script>
</body>
</html>