Bootstrap

uniapp——预览图片

<block v-for="(img,imgIndex) in item.images" :key="imgIndex">
	<image :src="i.image(img)" mode="aspectFill" :show-menu-by-longpress="true"
		@click.stop="preview(img,item.images)"></image>
</block>
const showOrNot = ref(true)//图片预览之后不触发onShow
onShow(() => {
	if(showOrNot.value){
		getIndexData() 
		common.getUserInfo()
	}
})
// 预览图片
function preview(e,preImgs) {
	i.previewImage(e,preImgs)
	showOrNot.value = false
}

封装的方法:

const previewImage = (index, params) => {
	let images = []
	params.forEach((item) => {
		images.push(image(item))
	})
	uni.previewImage({
		current: image(index),
		urls: images,
		loop: true,
		longPressActions: true
	})
}
;