vue 日期格式化

2020-02-14  本文已影响0人  这是这时
<template>
  <div>
     <div>日期:{{new Date | dat}}</div>
  </div>
</template>
<script>
export default {
filters:{
dat(val) {
    var year = val.getFullYear();
    var month =
    val.getMonth() + 1 > 9 ? val.getMonth() + 1 : "0" + (val.getMonth() + 1);
    var d = val.getDate();
    return year + "-" + month + "-" + d;
}}};
上一篇 下一篇

猜你喜欢

热点阅读