zhanglw
zhanglw
  • 发布:2022-12-15 11:44
  • 更新:2024-02-18 15:21
  • 阅读:572

国际化 vue3 i18n 命名插值 动态内容 h5有效,APP无效

分类:uni-app

vue3 vue-i18n

// locale 文件  
 "common.hello": "{msg} world",  
 "common.minutes": "1 分钟 | {count} 分钟",  

vue 文件

<script lang="ts" setup>  
import { useI18n } from 'vue-i18n'  
const {locale ,t} = useI18n()  

console.log('xxxxxxxxxxxxxxxxxxxxxxxxxx')  
console.log(t('common.hello', {mag:'hello'}))  
console.log(t('common.minutes', {count:5}))  
console.log('xxxxxxxxxxxxxxxxxxxxxxxxxx')  

</script>

分别运行到H5 和 安卓APP, 打印结果:

// 运行到 H5  
xxxxxxxxxxxxxxxxxxxxxxxxxx  
 hello world   
 5 分钟   
xxxxxxxxxxxxxxxxxxxxxxxxxx   

// 运行到 安卓APP  
 xxxxxxxxxxxxxxxxxxxxxxxxxx   
 {msg} world   
 1 分钟 | {count} 分钟   
 xxxxxxxxxxxxxxxxxxxxxxxxxx 

可以看到 APP 是原封不动的 将字符串打印出来了,H5传递了动态内容

2022-12-15 11:44 负责人:YUANRJ 分享
已邀请:
素食先生

素食先生

确实存在这个bug,我新建了两个项目,一个vue2一个vue3,选择的是hello i18n 这个模板,分别编译运行,国际化 vue3 i18n 命名插值 动态内容 h5有效,APP无效

l***@163.com

l***@163.com

求官方解决

要回复问题请先登录注册