rich-text nodes屬性需要數組,所有需要轉換成數組
import parse from 'mini-html-parser2'
//標籤需要結束符
this.setData({
contentStr: this.data.specialStore.introduction.replace(/<br>/g,'<br/>')
})
parse(this.data.contentStr, (err, htmlNodes) => {
if (!err) {
console.log(htmlNodes)
self.setData({
"introduction":htmlNodes
});
}
})
轉換後成數組後還是無法解析,那可能img轉換有誤,可能是因爲同樣缺少結束標識符/,所以還需要轉換下