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