mirari / vue3-viewer

Image viewer component for vue 3.x, supports rotation, scale, zoom and so on, based on viewer.js
MIT License
40 stars 2 forks source link

v-viewer.js:414 Uncaught TypeError: Cannot set properties of undefined (setting '$viewerApi') #5

Open w569638598 opened 10 months ago

w569638598 commented 10 months ago

main.ts // 图片预览插件 import 'viewerjs/dist/viewer.css' import VueViewer from 'v-viewer' app.use(VueViewer) 组件内 `

                </div>`
mirari commented 10 months ago

信息不足无法判断,建议先检查vue大版本是否一致

w569638598 commented 10 months ago

"v-viewer": "^3.0.11", "viewerjs": "^1.11.6", "vue": "^3.2.37",

w569638598 commented 10 months ago

npm install v-viewer@next viewerjs,这个安装的

mirari commented 10 months ago

https://codesandbox.io/s/vue3-viewer-wfw2zk 可参考示例对照代码

w569638598 commented 10 months ago

按文档,先安装依赖 npm install v-viewer@next viewerjs 然后(我是全局)注册组件 import 'viewerjs/dist/viewer.css' import VueViewer from 'v-viewer' app.use(VueViewer) 然后就是组件内使用 <div :class="['imgC' + props.orderInfo.detail.ticket_image.length]" v-viewer> <template v-for="(item, index) in props.orderInfo.detail.ticket_image" :key="index"> <img :src="item" alt=""> </template> </div> 组件内使用只需要在img的父级标签或者循环标签上加v-viewer就可以了。 刚才你给我发地址改了下。也是这样用的。所以我想问一下,什么情况下会报$viewerApi这个错误 微信截图_20231025160136

mirari commented 10 months ago

如果是说Cannot set properties of undefined (setting '$viewerApi')这个错误,一般是版本不一致时出现的,比如vue3安装了vue2的v-viewer