vue-i18n:带有 html 标签的组件插值

Jör*_*örn 8 vue.js vue-i18n

我正在使用这里描述的组件插值,但在我的翻译字符串中还有一些 html 标签用于格式化。我该如何处理?

<i18n
    path="description"
    tag="p"
    :places="{ value1, value2, routerLink }"
/>
Run Code Online (Sandbox Code Playgroud)

我的 .yml 文件中的相应键如下所示:

description: Lorem ipsum <nobr><strong>{value1}&#8201;%</strong></nobr> some more text <nobr><strong>{value2}&#8201;%</strong></nobr> and some more text. Go to {routerLink} for more info.
Run Code Online (Sandbox Code Playgroud)

小智 1

尝试使用v-html指令

<i18n
    v-html="description"
    tag="p"
    :places="{ value1, value2, routerLink }"
/>
Run Code Online (Sandbox Code Playgroud)

另一种方法是使用计算来解释 HTML 实体,请参阅此