将富文本内容进行格式化即可 具体代码如下
res.articleContent = res.articleContent && res.articleContent.replace(/(\s{2,})(?![^<>]*>)/g, function(match) {
return match.replace(/ /g, ' ');
});
具体逻辑就是匹配非html 之外的空格替换为 这种空格即可 , 因为html 之内的空格 如果替换成 u-parse 就解析不了该html 包包括行内的style 和class 等等 都无法解析 导致富文本样式丢失