延迟加载时en.js
或ja.js
是什么格式?下面的代码不起作用:
// en.js
export default
{
title: 'Title',
greeting: 'How are you'
};
和
import Vue from 'vue';
import InventoryList from "./components/InventoryList";
import VueI18n from 'vue-i18n';
import messages from 'lang/fa';
Vue.use(VueI18n);
const i18n = new VueI18n({
locale: 'en',
fallbackLocale: 'en',
messages
});
Vue.component('inventory-list', InventoryList);
const app = new Vue({
i18n,
el: '#app',
});
我该怎么办?
最佳答案
您需要包含所有语言文件并将它们分配给 VueI18n
init 调用中的 messages
键。
像这样:
import fa from './lang/fa' // relative path
import en from './lang/en' // relative path
...
const i18n = new VueI18n({
locale: 'en',
fallbackLocale: 'en',
messages: {
en,
fa
}
});
关于javascript - 延迟加载 vue-i18n 中 `en.js` 或 `ja.js` 的格式是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55458370/