66 lines
		
	
	
		
			1022 B
		
	
	
	
		
			Vue
		
	
	
	
			
		
		
	
	
			66 lines
		
	
	
		
			1022 B
		
	
	
	
		
			Vue
		
	
	
	
| <template>
 | |
| 	<view class="preBigImgWrap" v-if="preImg" @click="cancelPreImg">
 | |
| 		<image class="bigImg" :src="imgSrc" mode="widthFix"></image>
 | |
| 	</view>
 | |
| </template>
 | |
| 
 | |
| <script>
 | |
| 	export default {
 | |
| 		name:"image-view",
 | |
| 		props:{
 | |
| 			//图片上传地址
 | |
| 			imgSrc: {
 | |
| 				type: String,
 | |
| 				default: ''
 | |
| 			},
 | |
| 		},
 | |
| 		data() {
 | |
| 			return {
 | |
| 				preImg:false,
 | |
| 			};
 | |
| 		},
 | |
| 		onShow(){
 | |
| 			this.preImg = true;
 | |
| 		},
 | |
| 		methods:{
 | |
| 			open(){
 | |
| 				this.preImg = true;
 | |
| 			},
 | |
| 			close(){
 | |
| 				this.preImg = false;
 | |
| 			},
 | |
| 			//预览
 | |
| 			preview(index,urls) {
 | |
| 				uni.previewImage({
 | |
| 					urls: urls,
 | |
| 					current: index,
 | |
| 				});
 | |
| 			},
 | |
| 			cancelPreImg(){
 | |
| 				this.close();
 | |
| 				this.$emit('cancelPreView',false)
 | |
| 			},
 | |
| 		},
 | |
| 	}
 | |
| </script>
 | |
| 
 | |
| <style scoped>
 | |
| .preBigImgWrap{
 | |
| 		width: 100%;
 | |
| 		height: 100%;
 | |
| 		position: fixed;
 | |
| 		top: 0;
 | |
| 		left: 0;
 | |
| 		z-index: 100;
 | |
| 		display: block;
 | |
| 		background-color: rgba(0, 0, 0, 0.8);
 | |
| 	}
 | |
| 	.bigImg{
 | |
| 		min-width: 90%;
 | |
| 		max-width: 100%;
 | |
| 		position: absolute;
 | |
| 		top: 50%;
 | |
| 		left: 50%;
 | |
| 		transform: translate(-50% ,-50%);
 | |
| 	}
 | |
| </style> |