0

使用 nuxt-i18n 时是否可以输出 html 而不是字符串作为对象值?

如果你能教我就太好了!

en.json

{
  "HELLO_WORLD": "<p>Hello World<p>"
}

页面/index.vue

<template>
  <div>
    { $t('HELLO_WORLD') }}
  </div>
</template>

■想要的结果

<div>
  <p>Hello World<p> ← html tag
</div>

■实际结果

<div>
  <p>Hello World<p> ← Tags are also strings
</div>
4

1 回答 1

1

只需使用以下代码替换您的模板:

<template>
  <div v-html="$t('HELLO_WORLD')">
  </div>
</template>
于 2020-02-07T14:13:00.950 回答