Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

img标签中没有src属性时会出错 #352

Open
volsifly opened this issue Aug 7, 2019 · 1 comment
Open

img标签中没有src属性时会出错 #352

volsifly opened this issue Aug 7, 2019 · 1 comment

Comments

@volsifly
Copy link

volsifly commented Aug 7, 2019

html2json.js里

var imgUrl = node.attr.src;
if (imgUrl[0] == '') {
imgUrl.splice(0, 1);
}

如果标签里没有src属性,imgUrl会为空,找不到0的数据报错了,需要加个判断

@lionten
Copy link

lionten commented Aug 23, 2019

是的,我也遇到过这个问题了;改成var imgUrl = node.attr.src || []即可。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants