Vue 模板 - 将 HTML 特殊字符(数字)转换为符号? [英] Vue template - convert HTML special characters (numberic) to symbols?

查看:64
本文介绍了Vue 模板 - 将 HTML 特殊字符(数字)转换为符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将特殊字符(数字)转换为 Vue 模板中的符号?

How can I convert special characters (numberic) to symbols in my Vue template?

例如我有这个 JSON 数据:

For instance I have this JSON data:

[{"id":"post91","slug":null,"title":"Breakfast & Tea"}]

如何转换 Breakfast &茶早餐&茶?

我的 Vue 模板:

<h3 class="heading">{{ item.title }}</h3>

有什么想法吗?

推荐答案

实际上最好的选择是使用 v-html:

The best option is using v-html actually:

<h3 class="heading" v-html="item.title"></h3>

不需要任何其他库.

这篇关于Vue 模板 - 将 HTML 特殊字符(数字)转换为符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆