Image viewer component for vue 3.x, supports rotation, scale, zoom and so on, based on viewer.js
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
main.ts
// 图片预览插件 import 'viewerjs/dist/viewer.css' import VueViewer from 'v-viewer' app.use(VueViewer)
组件内 `信息不足无法判断,建议先检查vue大版本是否一致
"v-viewer": "^3.0.11", "viewerjs": "^1.11.6", "vue": "^3.2.37",
npm install v-viewer@next viewerjs,这个安装的
https://codesandbox.io/s/vue3-viewer-wfw2zk 可参考示例对照代码
按文档,先安装依赖![微信截图_20231025160136](https://github.com/mirari/vue3-viewer/assets/30279222/f9e0096a-c317-4ac3-aa07-ca8387b25519)
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这个错误如果是说
Cannot set properties of undefined (setting '$viewerApi')
这个错误,一般是版本不一致时出现的,比如vue3安装了vue2的v-viewer