网页中显示文字时,带#开始和结束的文字蓝色高亮,就像微博话题同样
效果以下html
<span v-html="parseComments('#吃货节#有什么好吃的')"></span> // 方法里面能够是变量,这里只是个演示
parseComments (value) { var exp exp = /(#|#)((?!#).)*(#|#)/g // 这里中文#和英文#都会识别 value = value.replace(/<[^>]*?>(.*?)/gi, '').replace(/(.*?)<\/[^>]*?>/gi, '').replace(exp, (item) => { let newVal = '<span class="text-blue">' + item + '</span>' return newVal }) return value }