Closed anyaooo closed 4 years ago
Are you using the latest version?
I'm using "viewerjs": "^1.5.0"
.
I'm also facing this problem when I try to invoke the following code.
new Viewer(document.getElementById('images')).show()
Uncaught TypeError: Cannot read property 'style' of undefined
at Viewer.open (webpack:///./node_modules/viewerjs/dist/viewer.js?:2652)
at Viewer.show (webpack:///./node_modules/viewerjs/dist/viewer.js?:1742)
at Viewer.show (webpack:///./node_modules/viewerjs/dist/viewer.js?:1721)
at onClick (webpack:///./src/components/estore-page/components/image-grid.tsx?:73)
at HTMLUnknownElement.callCallback (react-dom.development.js:188)
at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
at invokeGuardedCallback (react-dom.development.js:292)
at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:306)
at executeDispatch (react-dom.development.js:389)
at executeDispatchesInOrder (react-dom.development.js:414)
@wongjiahau Any online demo? I cannot reppear it.
@wongjiahau Try this:
const viewer = new Viewer(
document.getElementById('viewer-container'),
{
hide() {
viewer.destroy()
},
}
).show()
@wongjiahau Any online demo? I cannot reppear it.
Thanks for the reply, I'm not sure if it's because I'm mixing this usage with React and caused this problem.
无法获取未定义或null引用的属性"style",地址在viewer.js 509行,setStyle 函数中