日渐肥胖的左
日渐肥胖的左
  • 发布:2022-03-16 12:03
  • 更新:2022-11-16 09:08
  • 阅读:901

#插件讨论# 【 富文本解析器uParse优化版,已在生产环境使用 - z***@qq.com 】uParse在ios百度端不展示解决方式

分类:uni-app

根据真机报错,推断ios端对props中类型为function的数据处理有错误。


可看出,报错信息说,接受的类型有错。

本人解决方式:
将u-parse.vue文件中computed中的nodes中代码修改。
nodes() {
const {
content,
noData,
imageProp,
startHandler,
endHandler,
charsHandler,
} = this;
const parseData = content || noData;
const customHandler = {
start: startHandler,
end: endHandler,
chars: charsHandler,
};
const results = HtmlToJson(parseData, customHandler, imageProp, this);
this.imageUrls = results.imageUrls;
console.log(results);
return results.nodes;
},

改为=>

nodes() {
const {
content,
noData,
imageProp,
startHandler,
endHandler,
charsHandler,
} = this;
const parseData = content || noData;
const customHandler = {
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;
console.log(results);
return results.nodes;
},
说白了就是他既然要函数就给他个函数。
本人解决方式不一定是最优解决方式。

2022-03-16 12:03 负责人:无 分享
已邀请:
日渐肥胖的左

日渐肥胖的左 (作者)

修改前:


修改后:

8***@qq.com

8***@qq.com

你真是我的好大哥感谢

8***@qq.com

8***@qq.com

非常完美的解决掉了问题

该问题目前已经被锁定, 无法添加新回复

  • 标题 / 粗斜体
  • 代码片段
  • 超链接 / 图片 / 视频
  • 列表 / 引用

文章内容较多时,可以用标题分段 :

## 大标题 
### 小标题

斜体 / 粗体 :

**粗体** 
*斜体*
***粗斜体***

代码片段 :

``` javascript
代码片段
```

超链接 :

[链接文字](链接地址) 例: [百度](http://www.baidu.com)

图片 :

![图片说明](图片地址) 例: ![百度logo](http://www.baidu.com/img/bdlogo.gif)

视频 :

!![视频说明](视频地址) 例: !![优酷视频](http://youku.com)

有序列表 :

1. 123
2. 123
3. 123

无序列表 :

- 123
- 123
- 123

引用 : ( 双回车后结束引用 )

> 引用内容
引用内容
引用内容