真机报错
nodes中接受的startHandler不是function类型,而是object类型。
优化
// computed中
nodes() {
const {
content,
noData,
imageProp,
startHandler,
startHandler
endHandler,
charsHandler,
} = this;
const parseData = content || noData;
const customHandler = {
// 对start进行修改
// 修改前
// start: startHandler,
// 修改后
start: (typeof startHandler === "function") ? startHandler: (node) => {
node.attr.class = null;
node.attr.style = null;
},
end: endHandler,
chars: charsHandler,
};
const results = HtmlToJson(parseData, customHandler, imageProp, this);
this.imageUrls = results.imageUrls;
return results.nodes;
},