VUE AntDesign DatePicker设置默认显示当前日期
1:main.js中引入依赖
import Vue from "vue"; import { DatePicker } from 'ant-design-vue'; import 'ant-design-vue/dist/antd.css'; #设置中文 import moment from 'moment'; import 'moment/locale/zh-cn' moment.locale('zh-cn');
Vue.use(DatePicker)
2:使用
<template> <div class="about"> <div> <a-date-picker placeholder="选择日期" :defaultValue="moment(getCurrentData(), 'YYYY-MM-DD')" :showToday="false"/> </div> </div> </template> <script> import moment from "moment"; export default { name: 'about', data(){ return { } }, methods: { moment, getCurrentData(){ return new Date().toLocaleDateString(); } } } </script>