image.uvue 1.6 KB
Newer Older
Y
init  
yurj26 已提交
1
<template>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
2 3 4 5
	<view>
		<page-head :title="title"></page-head>
		<view class="uni-padding-wrap uni-common-mt">
			<view class="uni-center" style="background:#FFFFFF;">
shutao-dc's avatar
shutao-dc 已提交
6
				<image class="image" :fade-show="true" mode="widthFix" :src="imageSrc" @error="error"
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
7 8 9 10 11 12 13 14 15 16
					@load="load"></image>
			</view>
			<view class="uni-btn-v">
				<button type="primary" @tap="imageFormat">图片格式示例</button>
			</view>
			<view class="uni-btn-v">
				<button type="primary" @tap="imageMode">图片缩放模式示例</button>
			</view>
			<view class="uni-btn-v">
				<button type="primary" @tap="imagePath">图片路径示例</button>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
17 18 19
			</view>
			<view class="uni-btn-v">
				<button type="primary" @tap="imageLarge">大图示例</button>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
20 21 22
			</view>
		</view>
	</view>
Y
init  
yurj26 已提交
23 24
</template>
<script>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
25 26 27
	export default {
		data() {
			return {
shutao-dc's avatar
shutao-dc 已提交
28
				title: 'image',
shutao-dc's avatar
shutao-dc 已提交
29
				imageSrc: "/static/test-image/logo.png",
shutao-dc's avatar
shutao-dc 已提交
30
				loadError: false
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
31 32 33
			}
		},
		methods: {
shutao-dc's avatar
shutao-dc 已提交
34 35
			error(event : ImageErrorEvent) {
				this.loadError = true
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
36 37
				console.log(event.type, event.detail);
			},
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
38
			load(event : ImageLoadEvent) {
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
				console.log(event.type, event.detail);
			},
			imageFormat() {
				uni.navigateTo({
					url: '/pages/component/image/image-format'
				});
			},
			imageMode() {
				uni.navigateTo({
					url: '/pages/component/image/image-mode'
				});
			},
			imagePath() {
				uni.navigateTo({
					url: '/pages/component/image/image-path'
				});
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
55 56 57 58 59
			},
			imageLarge() {
				uni.navigateTo({
					url: '/pages/component/image/image-large'
				});
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
60 61 62
			}
		}
	}
Y
init  
yurj26 已提交
63 64
</script>
<style>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
65 66 67 68
	.image {
		margin: 40rpx auto;
		width: 200rpx;
	}
shutao-dc's avatar
shutao-dc 已提交
69
</style>