The reason for this error is:
el-date-picker displays in English by default. I want to set it to display in Chinese.
An error occurs after using the following method:
<template>
<el-config-provider :locale="locale">
<el-date-picker
size="large"
v-model="dateValue"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
format="yyyy-MM-dd "
value-format="yyyy-MM-dd"
@change="customDate"
>
</el-date-picker>
</el-config-provider>
</template>
<script setup>
import {
ElConfigProvider } from 'element-plus';
import locale from 'element-plus/lib/locale/lang/zh-cn';
</script>
solution:
Place the following code:
import localeZH from ‘element-plus/lib/locale/lang/zh-cn’
Replace with:
import localeZH from ‘element-plus/es/locale/lang/zh-cn’
That's solved
However, I am using vue3, and the date value obtained after adding this format is actually: yyyy-12-Fr 00:00:00
I finally found the solution later:Vue3’s time format requires the year, month and day to be capitalized! ! ! Change it to the following writing
format=“YYYY-MM-DD hh:mm:ss”
value-format=“YYYY-MM-DD hh:mm:ss”