「Vue — 插件」国际化vue-i18n

1:npm install vue-i18n 2:在main.js中

1import VueI18n from 'vue-i18n' //引入 2Vue.use(VueI18n) //通过插件方式挂载 3 4/*---------使用语言包-----------*/ 5const i18n = new VueI18n({ 6 locale: 'zh-CN', // 语言标识 7 //this.$i18n.locale // 通过切换locale的值来实现语言切换 8 messages: { 9 'zh-CN': require('./common/lang/zh'), // 中文语言包 10 'en-US': require('./common/lang/en') // 英文语言包 11 } 12}); 13 14new Vue({ 15 i18n, 16 router, 17 store, 18 render: h => h(App) 19}).$mount('#app') 20

3:在src文件夹下新建common文件夹新建lang文件夹新建en.js和zh.js文件,分别存放英文和中文语言包 4:示例:en.js中

1module.exports = { 2 index: { 3 banner: { 4 title: 'RheinKoester SAP', 5 detail1: 'The SAP Business Intelligence Solution provides comprehensive business intelligence capabilities, giving users the ability to make effective and informed decisions based on solid data and analysis', 6 detail2: 'All users, from high-end analysts to ordinary business users, have access to the information they need, with as little reliance on IT resources and developers as possible.' 7 }, 8 titleBox: { 9 box1: { 10 LTitle: "SAP products", 11 MTitle: 'SAP产品' 12 }, 13 box2: { 14 LTitle: "PA Global Consultant Certification", 15 MTitle: 'PA全球顾问认证' 16 }, 17 box3: { 18 LTitle: "Education and training resources", 19 MTitle: '教育培训资源' 20 }, 21 box4: { 22 LTitle: "Education and training solutions", 23 MTitle: '教育培训解决方案' 24 } 25 } 26 } 27}

5:示例:zh.js中

1module.exports = { 2 index: { 3 banner: { 4 title: '莱茵科斯特 SAP', 5 detail1: 'SAP商务智能解决方案提供全面的商务智能功能,赋予用户根据坚实的数据和分析结果来制定有效且明智决策的能力。', 6 detail2: '从高端分析师到普通业务用户的所有用户都可访问他们所需的信息,尽可能不依赖 IT 资源和开发人员。' 7 }, 8 titleBox: { 9 box1: { 10 LTitle: "SAP产品", 11 MTitle: 'SAP products' 12 }, 13 box2: { 14 LTitle: "PA全球顾问认证", 15 MTitle: 'PA Global Consultant Certification' 16 }, 17 box3: { 18 LTitle: "教育培训资源", 19 MTitle: 'Education and training resources' 20 }, 21 box4: { 22 LTitle: "教育培训解决方案", 23 MTitle: 'Education and training solutions' 24 } 25 } 26 } 27}

6:使用示例

1<div class="title">{{$t('index.banner.title')}}</div> 2v-for="(item,index) in $t('index.threeBox')"

参考链接:https://blog.csdn.net/qq_38543537/article/details/90696648

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

java将前端的json数组字符串转换为列表

记录下在前端通过ajax提交了一个json数组的字符串,在后端如何转换为列表。前端数据转化与请求varcontracts{id:'1',name:'yanggb合同1'},{id:'2',name:'yanggb合同2'},{id:'3',name:'yang