typescript - 如何将参数传递给翻译
问题描述
我正在使用带有 TS 的 vuejs 3。
我在 TS 中创建了这样的翻译文件:
索引.ts:
export default {
'example': 'example',
}
然后以这种方式使用它:
{{ $t('example') }}
现在我想将参数传递给翻译,例如:
索引.ts:
export default {
'hi_man': 'Hi {name}', //where the name is the parameter
}
我怎样才能做到这一点?
解决方案
也许您应该考虑阅读文档:https ://kazupon.github.io/vue-i18n/guide/formatting.html#named-formatting
<p>{{ $t('hi_man', { name: 'Monkey' }) }}</p>
推荐阅读
- javascript - 映射和传递 onClick 函数作为道具后如何定位特定元素
- swift - 如何编辑隐藏在 Xcode Storyboard 中其他视图后面的视图?
- ssl - 有什么方法可以在免费的 heroku dyno 上添加免费的 SSL 证书?
- web-scraping - 使用 Google Search API 访问 Google Enchanced Events 结果的方法?
- r - 在R中循环一个数据帧以有条件地生成另一个数据帧,第一个数据帧中的每一行都有一个或多个行
- c++ - 重叠 Boost 协程的异常安全
- sql - 如何在 Teradata 中按等级(而不是行)计算滚动平均值?
- sql-server - 从其他数据库复制数据与直接查询它 SQL-Server
- laravel - Laravel hasMany 关系分离所有
- r - 使用 Quantmod 从雅虎财经下载数据失败