不得不說Antd的確蠻好用的,但是還是要吐槽,遇到一點問題百度基本上解決不了,而且文檔寫的也的確不怎么樣
就這個日期選擇器,默認竟然不支持中文???而且百度了半天都是什么鬼???
這是默認效果

默認效果.png
這是之后的效果

完成效果.png
第一步:根據(jù)官方文檔導(dǎo)入下面的代碼(你可以放在使用日期選擇框的界面也可以放在main.js里面)
// import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN';
import moment from 'moment';
import 'moment/locale/zh-cn';
moment.locale('zh-cn');
第二步:對上一步進行一個改善
2-1:在你使用日期選擇器的頁面加入下面的這個變量(變量名隨意,我就叫 locale)
locale:{
"lang": {
"placeholder": "請選擇日期",
"today": "今天",
"yearFormat": "YYYY",
"dateFormat": "M/D/YYYY",
"dayFormat": "D",
"dateTimeFormat": "M/D/YYYY HH:mm:ss",
"monthFormat": "MMMM"
}
}
2-2:在你的日期選擇框上加上這句代碼 :locale=locale

代碼.png
2-3:最終效果

完成效果.png
更多配置看這里
locale:{
"lang": {
"placeholder": "請選擇日期",
"rangePlaceholder": ["Start date", "End date"],
"today": "今天",
"now": "Now",
"backToToday": "Back to today",
"ok": "Ok",
"clear": "Clear",
"month": "Month",
"year": "Year",
"timeSelect": "Select time",
"dateSelect": "Select date",
"monthSelect": "Choose a month",
"yearSelect": "Choose a year",
"decadeSelect": "Choose a decade",
"yearFormat": "YYYY",
"dateFormat": "M/D/YYYY",
"dayFormat": "D",
"dateTimeFormat": "M/D/YYYY HH:mm:ss",
"monthFormat": "MMMM",
"monthBeforeYear": true,
"previousMonth": "Previous month (PageUp)",
"nextMonth": "Next month (PageDown)",
"previousYear": "Last year (Control + left)",
"nextYear": "Next year (Control + right)",
"previousDecade": "Last decade",
"nextDecade": "Next decade",
"previousCentury": "Last century",
"nextCentury": "Next century"
},
"timePickerLocale": {
"placeholder": "Select time"
}
}