【问题标题】:How to pass parameters to Vue.js i18n <i18n-t> tag如何将参数传递给 Vue.js i18n <i18n-t> 标签
【发布时间】:2022-11-14 05:21:02
【问题描述】:
我正在使用 vue.js i18n 包,更具体地说,使用 i18n-t 标记进行翻译,但我在文档中找不到任何地方如何传递参数?
这里是标签...
<i18n-t :keypath="title" scope="parent">
</i18n-t>
通常我使用 v-t 表示法传递参数...
v-t="{ path: title, args: { param1: 'value' } }
但我使用该组件,因为它是迄今为止我发现访问父范围内的翻译的唯一方法......
【问题讨论】:
标签:
vue.js
vuejs3
vue-i18n
【解决方案1】:
如果您的 param 翻译类似于:
messages: {
en: {
title: 'Some {value} title.',
}
}
你可以试试slots syntax:
<i18n-t keypath="title" tag="p">
<template v-slot:value>
<span>{{ myValue }}</span>
</template>
</i18n-t>