问题描述
我将 vuejs 3 与 TS 一起使用。
我在 TS 中创建了这样的翻译文件:
index.ts:
export default {
'example': 'example',}
为了然后以这种方式使用它:
{{ $t('example') }}
现在我想向翻译传递一个参数,例如:
index.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>