123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <template>
- <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 class="uni-btn-v">
- <button type="primary" @tap="imageLong">长图示例</button>
- </view>
- </view>
- <view v-if="autoTest">
- <image :src="setCookieImage"></image>
- <image :src="verifyCookieImage" @error="error"></image>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- title: 'image',
- imageSrc: "/static/test-image/logo.png" as string.ImageURIString,
- loadError: false,
- // 自动化测试
- autoTest: false,
- setCookieImage: "",
- verifyCookieImage: "",
- eventLoad: null as UTSJSONObject | null,
- eventError: null as UTSJSONObject | null
- }
- },
- methods: {
- error(event : ImageErrorEvent) {
- this.loadError = true
- console.log(event.type, event.detail);
- if (this.autoTest) {
- this.eventError = {
- "tagName": event.target?.tagName,
- "type": event.type,
- // "errMsg": event.detail.errMsg
- };
- }
- },
- load(event : ImageLoadEvent) {
- console.log(event.type, event.detail);
- if (this.autoTest) {
- this.eventLoad = {
- "tagName": event.target?.tagName,
- "type": event.type,
- "width": event.detail.width,
- "height": event.detail.height
- };
- }
- },
- 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'
- });
- },
- imageLong() {
- uni.navigateTo({
- url: '/pages/component/image/image-long'
- });
- }
- }
- }
- </script>
- <style>
- .image {
- margin: 20px auto;
- width: 100px;
- }
- </style>
|