美文网首页
Vue商品放大镜 VuePhotoZoomPro(IE下不兼容报

Vue商品放大镜 VuePhotoZoomPro(IE下不兼容报

作者: Luv_coco | 来源:发表于2020-04-23 17:48 被阅读0次

GitHub地址

https://github.com/Mater1996/vue-photo-zoom-pro

使用

官方npm使用方法就不写了,直接上遇到的问题,报对象不支持“toJSON”属性或方法
直接把 ./ src/ components/目录下的vue-photo-zoom-pro.vue文件拷贝到自己项目的components下自己注册成vue组件使用,在vue-photo-zoom-pro.vue全局搜索toJSON删除掉,可以解决报错

const rect = dom.getBoundingClientRect().toJSON();
this.imgInfo = $img.getBoundingClientRect().toJSON();

改成下面

const rect = dom.getBoundingClientRect();
this.imgInfo = $img.getBoundingClientRect();

最好把下面的也修改了

validImgResize(imgInfo) {
    return JSON.stringify(this.imgInfo) !== JSON.stringify(imgInfo);
},

改成下面,因为在低版本的VuePhotoZoomPro下IE下这两个值stringify后是空对象,然后就相等了,现在最新版没问题

validImgResize(imgInfo) {
    return this.imgInfo !== imgInfo
},

相关文章

网友评论

      本文标题:Vue商品放大镜 VuePhotoZoomPro(IE下不兼容报

      本文链接:https://www.haomeiwen.com/subject/rpgaihtx.html