vue去掉字符串中的标签元素

时间:2021-07-27 15:42:32   收藏:0   阅读:327

1、使用vue指令:v-html

// content=‘<p>我是带标签的字符串</p>‘
<span v-html="content"></span>

2、使用正则表达式

// 去掉html字符串中的所有标签元素
export function delHtmlTag (str) {
  return str.replace(/<[^>]+>/g, ‘‘)
}
// 使用 content=‘<p>我是带标签的字符串</p>‘
<span>{{ delHtmlTag(content) }}</span>

原文:https://www.cnblogs.com/kanie-life/p/15065072.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!