1、引入

	import { ImagePreview } from "vant";

2、使用

//ImagePreview和其他组件不同,不是通过HTML结构的方式来使用,而是通过函数调用的方式。使用前需要先引入它。
//为你的图片加入点击事件,就会展示大图了。
    <img v-for="(item,index) in pictureList" :key="index" class="more-img" :src="item.url" @click="HandleclickImg(index)"/>
HandleclickImg(index) {
	ImagePreview({
	  images: [
	    'https://img.yzcdn.cn/1.jpg',
	    'https://img.yzcdn.cn/2.jpg'
	  ],
	  startPosition: index,
	  onClose() {
	    // do something
	  }
	});
}

Logo

Vue社区为您提供最前沿的新闻资讯和知识内容

更多推荐