我正在尝试vue-i18n,并根据语言将翻译保存在文件中。
en.json
{
"Msg1": "You have ",
"Msg2": " results."
}
showResult.vue
{{ $t('Msg1')}} {{totalResults}} {{ $t('Msg2')}}
哪个可以显示示例输出,但是如果我想将所有内容合并到en.json的一行中,例如:
{
"Msg1": "You have {{totalResults}} results."
}
对于showResult.vue,我已更改为它,我不确定这是正确的方法:
{{Msg1}}
下面是我希望得到的示例输出:
You have 10 results.
<< [10是{{totalResults}}中的值,该值将相应更改。我该怎么办?
谢谢。{{ $t('Msg1', { totalResults: 10 }) }
https://kazupon.github.io/vue-i18n/guide/formatting.html#named-formatting