我已经将我的项目从 Vite 2.x 更新到 Vite 3.0.2,突然出现以下错误:
[plugin:vite:import-analysis] 无法解析导入分析源,因为内容包含无效的 JS 语法。如果您使用 JSX,请确保使用 .jsx 或 .tsx 扩展名命名该文件。
/Volumes/Disk/Web/wce-system/src/i18n.js:51:20
i18n.js 文件中没有任何问题,因为它在 Vite 2.x 上运行良好,但我将代码放在这里以防万一您需要:
import { nextTick } from "vue"
import { createI18n } from "vue-i18n"
import axios from "axios"
import tr from "@/locales/tr.json"
import en from "@/locales/en.json"
export const SUPPORT_LOCALES = ["tr", "en"]
export function setupI18n(options = { locale: "tr" }) {
const i18n = createI18n(options)
setI18nLanguage(i18n, options.locale)
return i18n
}
export function setI18nLanguage(i18n, locale, url) {
if (i18n.mode === "legacy") { …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的 Vue3(带有 Vite 设置)项目国际化,并且@intlify/vite-plugin-vue-i18n我正在使用<script setup>
我不断得到Uncaught TypeError: i18n.global is undefined,但一切似乎都是正确的。我什至尝试过官方文档中的原始代码,您可以在这里找到
无论我做什么,Vue 或 i18n 都找不到globali18n 的属性。
所以我的 i18n.js 是这样的:
import { nextTick } from "vue";
import { createI18n } from "vue-i18n";
import axios from "axios";
import tr from "../src/locales/tr.json";
import en from "../src/locales/en.json";
export const SUPPORT_LOCALES = ["tr", "en"];
export function setupI18n(options = { locale: "tr" }) {
const i18n = createI18n(options);
setI18nLanguage(i18n, options.locale);
return i18n;
}
export function setI18nLanguage(i18n, locale) {
if …Run Code Online (Sandbox Code Playgroud)