uniapp 大图预览

uniapp yekong

微信小程序外包项目中,经常会遇到要求的要求是页面中要可以点击大图预览。

html

<view class="attachments">
	<image @click="previewImg([imgSrc],0)" class="attachmentsicon" :src="imgSrc" mode="aspectFit"></image>
</view>

js

previewImg(imgUrlList, index) {
	let _this = this;
	// #ifdef MP
	uni.previewImage({
		current: index - 1,
		urls: imgUrlList,
		indicator: 'number',
		loop: true
	});
	// #endif

	// #ifndef MP
	uni.previewImage({
		current: index - 1,
		urls: imgUrlList,
		indicator: 'number',
		loop: true
	});
	// #endif
},
喜欢