1:main.js中引入依賴css
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');
2:使用vue
<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>