如何在 nuxt-i18n 中添加 CSS 样式?
我有以下翻译:
en.js
test: {
hello: 'My name is Ben'
}
如果我想让“名字”是蓝色的单词,其他单词是黑色的。
我尝试过以下代码: en.js
test: {
hello: 'My <span style="color:blue">name<span> is Ben'
}
但它会显示我的名称是 Ben
我该如何纠正它?
I have a following translation:
en.js
test: {
hello: 'My name is Ben'
}
If I want to let 'name' is blue word,other word is black.
I have tried following code:en.js
test: {
hello: 'My <span style="color:blue">name<span> is Ben'
}
But it will showMy <span style="color:blue">name<span> is Ben
How can I correct it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的 i18n JSON(仅文本)中不应包含代码,而应在模板中使用类似这样的条件
You should not have code in your i18n JSON (just text), rather use a conditional like this in your template
我推荐的slots语法
你可以参考文档:
https://vue-i18n.intlify.dev/ Guide/advanced/component.html#slots-syntax-usage
I recommend the slots syntax
you can refer to the documentation:
https://vue-i18n.intlify.dev/guide/advanced/component.html#slots-syntax-usage