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

全局引用,两个组件内都引入标签,一个组件内的正常,另个组件内报错 #45

Open
codecatgo opened this issue Jul 10, 2018 · 2 comments

Comments

@codecatgo
Copy link

全局引用,两个组件内都引入标签,一个组件内的正常,另个组件内报错Cannot read property 'x' of undefined

@guxuehua
Copy link

解决了吗。我也遇到这样 的问题

@onlunar
Copy link

onlunar commented Feb 1, 2019

产生报错的操作为点击缩略图,追踪堆栈后发现报错部分
Cannot read property 'x' of undefined

一级堆栈发生在PhotoSwipe的源码pageswipe.js:497
x = _mainScrollPos.x + delta * _options.mainScrollEndFriction;
其中_mainScrollPos来自_getEmptyPoint()

二级堆栈发生在pageswipe.js:2661
分析调用关系initialPanOffset->_panOffset ->_getEmptyPoint()

报错是由_mainScrollPos为undefined所致,而_getEmptyPoint函数只是返回一个简单对象{x:0,y:0},在无法推知执行先后顺序的情况下 只能推测_getEmptyPoint执行前被阻塞了

最后解决还是参考了PS的Issue#666Issue#1410Issue#1361(17年6月),作者提到了当传入图片参数没有w和h的情况下,就会报这个错,但是作者提到会在之后的版本加入默认的图片大小来处理这个问题,所以讲道理@LS1231 把(快1年前的)源码内的PS依赖版本更新一下应该就能解决。

我的情况:传入的数组图片参数里没有h,但是有w,会报这个错(试了一下只有h没有w则不会报错)
解决办法:computed里遍历数组的时候手动封装一下默认值的逻辑使得w、h必存在

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

3 participants