import { createApp } from 'vue'
|
import { createPinia } from 'pinia'
|
import ElementPlus from 'element-plus'
|
import 'element-plus/dist/index.css'
|
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
import App from './App.vue'
|
import router from './router'
|
import zhCn from 'element-plus/es/locale/lang/zh-cn'
|
|
import { createI18n } from 'vue-i18n'
|
|
const app = createApp(App)
|
|
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
app.component(key, component)
|
}
|
|
const messages = {
|
zh: {
|
welcome: '欢迎使用 Vue-i18n',
|
button: '按钮',
|
tip: '这是固定的中文文案'
|
// 你可以根据业务需求添加更多中文文案
|
}
|
}
|
|
// 4. 创建 i18n 实例(仅配置中文)
|
const i18n = createI18n({
|
legacy: false, // 适配 Vue 3 组合式 API
|
locale: 'zh', // 固定为中文
|
fallbackLocale: 'zh', // 容错也指向中文(避免意外显示其他语言)
|
messages
|
})
|
|
app.use(createPinia())
|
app.use(router)
|
// app.use(ElementPlus)
|
app.use(ElementPlus, {
|
locale: zhCn // 关键:指定 Element Plus 语言为中文
|
})
|
app.use(i18n)
|
app.mount('#app')
|