项目场景:
uniapp的富文本编辑器editor解析不了富文本编辑器解析不了article 标签和 section 标签
原因分析:
富文本编辑器可解析的标签:根据微信小程序和 `uni-app` 的文档,富文本组件 `<rich-text>` 只支持一部分 HTML 标签。 // 这些标签包括:`a`, `abbr`, `b`, `blockquote`, `br`, `code`, `col`, `colgroup`, `dd`, `del`, `div`, `dl`, `dt`, `em`, `fieldset`, `h1` 到 `h6`, `hr`, `i`, `img`, // `ins`, `label`, `legend`, `li`, `ol`, `p`, `q`, `span`, `strong`, `sub`, `sup`, `table`, `tbody`, `td`, `tfoot`, `th`, `thead`, `tr`, `ul`。
解决方案:
将article 标签和 section 标签转为可解析的p标签或者div标签(推荐p标签)
this.content = this.content.replace(
/<article[^>]*>/g, '<p>').replace(/<section[^>]*>/g, '<p>')
this.editorCtx.setContents({
html: this.content //this.EditGoodsDetail.content为赋值内容。
})