image.uvue 2.1 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
  <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>
20 21 22 23
    </view>
    <view v-if="autoTest">
      <image :src="setCookieImage"></image>
      <image :src="verifyCookieImage" @error="error"></image>
H
hdx 已提交
24 25
    </view>
  </view>
Y
init  
yurj26 已提交
26 27
</template>
<script>
H
hdx 已提交
28 29 30 31
  export default {
    data() {
      return {
        title: 'image',
W
wanganxp 已提交
32
        imageSrc: "/static/test-image/logo.png" as string.ImageURIString,
33 34 35 36 37
        loadError: false,
        // 自动化测试
        autoTest: false,
        setCookieImage: "",
        verifyCookieImage: ""
H
hdx 已提交
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
      }
    },
    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 已提交
70 71
</script>
<style>
H
hdx 已提交
72 73 74 75
  .image {
    margin: 20px auto;
    width: 100px;
  }
shutao-dc's avatar
shutao-dc 已提交
76
</style>