js如何转义和反转义html特殊字符

js如何转义和反转义html特殊字符,第1张

js中的特殊字符,加上转义符\ 。

例如:

var txt="We are the so-called "Vikings" from the north." document.write(txt) 【错误】

var txt="We are the so-called \"Vikings\" from the north." document.write(txt) 【正确】

el-tooltiphtml转义

Vue.js提供了一个内置过滤器,可以用来转义HTML:

```

<div v-html="myHtml | escapeHtml"></div>

```

其中,`escapeHtml`是Vue.js内置的过滤器,可以将HTML字符串转义为安全的文本。el-tooltiphtml转义


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/6107105.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-15
下一篇 2023-03-15

发表评论

登录后才能评论

评论列表(0条)

保存