请选择 进入手机版 | 继续访问电脑版
 找回密码
 立即注册
搜索

技术分享 快应用中引入json文件

0
回复
1280
查看
[复制链接]

6

主题

18

帖子

120

积分

 楼主| 2021-9-3 19:15:23 显示全部楼层 |阅读模式

项目中静态资源一般是放在json里面,因为很多语言都支持json,通过import的方式引入。

1、在 src/i18n 目录新增zh.json文件中, 添加如下代码


 en.json


{
  "name": "Epidemic prevention health code",
  "loadingMsg": "Loading",
  "bind": "To bind",
  "updateTime": "UpdateTime",
  "servicing": "Currently unavailable in server maintenance",
  "outdateLine": "Login expired!",
  "abnormal": "There is an exception",
  "noabnormal": "No abnormality seen",
  "noBindMes": "You are not identity bound in the National Government Platform fast application or binding expired."
}



在 src/demo/index目录新增zh.json文件中, 添加如下代码

2. 引入 

import en from '../i18n/en.json'



3.使用,某些代码会省略


 <text class="none-text">{{ en.servicing }}</text>
 
   private: {
    en,
    zh,
  },



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册