问题描述:
在使用element-UI开发的过程中,遇到了一个很烦人的问题。
这个框架的日期时间选择控件都是英文版本,在实际应用的过程中,客户会觉得不方便,为了修改这个问题,绞尽脑汁了很久,在网上搜索了很多种方法,效果都不尽人意,后来突然恍然大悟,做了如下修改~
问题解决
网上大多数的方法都是要配置全局变量,即main.js,但是我现在的项目里面没有统一的全局变量配置,所以方法不适用。
只能通过修改引入element-UI的js,来达到目的。
找到element-plus.js,搜索datepicker,将里面的内容按照如下方式替换
datepicker: {
now: "当前时间",
today: "Today",
cancel: "Cancel",
clear: "Clear",
confirm: "确认",
dateTablePrompt: "Use the arrow keys and enter to select the day of the month",
monthTablePrompt: "Use the arrow keys and enter to select the month",
yearTablePrompt: "Use the arrow keys and enter to select the year",
selectedDate: "Selected date",
selectDate: "选择日期",
selectTime: "选择时间",
startDate: "开始日期",
startTime: "开始时间",
endDate: "结束日期",
endTime: "结束时间",
prevYear: "Previous Year",
nextYear: "Next Year",
prevMonth: "Previous Month",
nextMonth: "Next Month",
year: "",
month1: "一月",
month2: "二月",
month3: "三月",
month4: "四月",
month5: "五月",
month6: "六月",
month7: "七月",
month8: "八月",
month9: "九月",
month10: "十月",
month11: "十一月",
month12: "十二月",
week: "week",
weeks: {
sun: "日",
mon: "一",
tue: "二",
wed: "三",
thu: "四",
fri: "五",
sat: "六"
},
weeksFull: {
sun: "日",
mon: "一",
tue: "二",
wed: "三",
thu: "四",
fri: "五",
sat: "六"
},
months: {
jan: "一月",
feb: "二月",
mar: "三月",
apr: "四月",
may: "五月",
jun: "六月",
jul: "七月",
aug: "八月",
sep: "九月",
oct: "十月",
nov: "十一月",
dec: "十二月"
}
},
注:这里我只修改了一部分,其他配置在我的项目中用不到,如果有需要,直接自行将英文改为中文就好啦~