<> introduction

Record in learning vue3.0 Yes, add i18n International translation function and problems .

<> problem

stay vue3.0 Make reference in i18n The reason for the error has been reported all the time :
Please check the version ! Please check the version ! Please check the version ! Currently I use "vue-i18n": “^9.0.0-beta.17”, Version compatible vue3.0.
// Install the latest version @next npm install vue-i18n@next
The official website is quoted as vue2.0 How to reference and mount versions , because vue3.0 Of vue The import method is import { createApp } from “vue”;
Unable to mount directly according to tradition .

<>vue3.0 Used in i18n record

step 1: install vue-i18n
npm install vue-i18n@next
step 2: establish language The folder stores the language variables of each version
language in index.js
// language import { createI18n } from 'vue-i18n' // introduce vue-i18n assembly // import { Imported components
export It came out variable } from 'vue-i18n' // register i8n Examples and language files are introduced const i18n = createI18n({ locale
: 'ch', // Default display language messages: { ch:require('./ch.js'), // Importing language files en:require(
'./en.js') } }) export default i18n; // take i18n Exposed , stay main.js Introduce mount in
language in ch.js
module.exports = { // Head menu header_menu: { logout: ' sign out ' } }
language in en.js
module.exports = { // Head menu header_menu: { logout: 'sign out' } }
main.js Mount in
import { createApp } from "vue"; import App from "./App.vue"; import router
from "./router"; import store from "./store"; import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css'; import VueI18n from './language'
createApp(App) .use(store) .use(router) .use(Antd) .use(VueI18n) .mount("#app");
Usage
// The format is $t(' variable ') {{ $t('header_menu.logout') }}

Technology
©2019-2020 Toolsou All rights reserved,
Hikvision - Embedded software written test questions C Language application 0 The length of array in memory and structure is 0 In depth analysis data structure --- The preorder of binary tree , Middle order , Subsequent traversal How to do it ipad Transfer of medium and super large files to computer elementui Shuttle box el-transfer Display list content text too long 2019 The 10th Blue Bridge Cup C/C++ A Summary after the National Games ( Beijing Tourism summary )unity Shooting games , Implementation of first person camera python of numpy Module detailed explanation and application case Study notes 【STM32】 Digital steering gear Horizontal and vertical linkage pan tilt Vue Used in Element Open for the first time el-dialog Solution for not getting element