vue解决iOS10-11、vant部分版本ImagePreview点击预览图片无法缩放回去的问题


html使用组件:

<div class="cell photo" @click.stop="imagesPreview(img.url)" :style=" 'background-image: url('+ img.url +')  " ></div>
<van-image-preview v-model="show" :images="images1" v-myOn:click="fn"></van-image-preview>
js使用自定义指令:
export default {
  name: "",
  data() {
    return {
      images1: [],
      show: false,
    };
  },
directives: {
    myOn: {
      bind(el, binding, vnode) {
        const event = binding.arg;
        const fn = binding.value;
        el.addEventListener(event, fn);
      },
    },
  },
  methods: {
    fn() {
      this.show = false;
    }
 
    imagesPreview(img) {
      this.images1 = [img];
      this.show = true;
    },
  }
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM