HTML文本转为纯字符文本
<span>{{ToText(data[index-1])}}</span>
在span中调用ToText函数
ToText(HTML){ var input = HTML; return input.replace(/<(style|script|iframe)[^>]*?>[\s\S]+?<\/\1\s*>/gi,'').replace(/<[^>]+?>/g,'').replace(/\s+/g,' ').replace(/ /g,' ').replace(/>/g,' '); }
ToText(HTML){ var input = HTML; if(input===null){ input=''; input = input.replace(/<\/?[^>]*>/g, ''); input = input.replace(/[|]*\n/, ''); input = input.replace(/ /gi, '') return input }else{ input = input.replace(/<\/?[^>]*>/g, ''); input = input.replace(/[|]*\n/, ''); input = input.replace(/ /gi, '') return input } },