Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
69f3716d
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6005
Star
91
Fork
164
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
69f3716d
编写于
8月 11, 2023
作者:
DCloud-yinjiacheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新image示例
上级
a09a3dc8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
72 addition
and
56 deletion
+72
-56
pages/component/image/image-format.uvue
pages/component/image/image-format.uvue
+29
-21
pages/component/image/image-large.uvue
pages/component/image/image-large.uvue
+2
-2
pages/component/image/image-mode.uvue
pages/component/image/image-mode.uvue
+8
-7
pages/component/image/image-path.uvue
pages/component/image/image-path.uvue
+23
-16
pages/component/image/image.uvue
pages/component/image/image.uvue
+10
-10
未找到文件。
pages/component/image/image-format.uvue
浏览文件 @
69f3716d
<template>
<view>
<
scroll-
view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-title">
<text class="uni-title-text">支持的图片格式示例</text>
</view>
<view v-for="(item,index) in
data
" :key="index">
<view v-for="(item,index) in
supportFormats
" :key="index">
<text class="uni-subtitle-text">{{item.format}}</text>
<view class="uni-center" style="background:#FFFFFF;">
<image class="image" mode="widthFix" :src="item.src"></image>
...
...
@@ -14,14 +14,14 @@
<view class="uni-title">
<text class="uni-title-text">暂不支持的格式</text>
</view>
<view>
<text class="uni-subtitle-text">
tif
</text>
<view
v-for="(item,index) in notSupportFormats" :key="index"
>
<text class="uni-subtitle-text">
{{item.format}}
</text>
<view class="uni-center" style="background:#FFFFFF;">
<image
src="/static/test-image/logo.tif
" @error="imageErrorEvent"></image>
<image
class="image" mode="widthFix" :src="item.src
" @error="imageErrorEvent"></image>
</view>
</view>
</view>
</view>
</
scroll-
view>
</template>
<script>
...
...
@@ -29,11 +29,7 @@
data() {
return {
title: 'image-format',
data: [
{
format: 'avif',
src: '/static/test-image/logo.avif' //TODO
},
supportFormats: [
{
format: 'bmp',
src: '/static/test-image/logo.bmp'
...
...
@@ -42,10 +38,6 @@
format: 'gif',
src: '/static/test-image/logo.gif'
},
{
format: 'heic',
src: '/static/test-image/logo.heic'
},
{
format: 'ico',
src: '/static/test-image/logo.ico'
...
...
@@ -61,22 +53,38 @@
{
format: 'webp',
src: '/static/test-image/logo.webp'
},
{
format: 'heic(Android10+支持)',
src: '/static/test-image/logo.heic'
}
] as Array<ImageFormat>,
notSupportFormats: [
{
format: 'avif',
src: '/static/test-image/logo.avif'
},
{
format: 'tif',
src: '/static/test-image/logo.tif'
}
] as Array
< ImageFormat
>
] as Array
<ImageFormat
>
}
},
methods: {
imageErrorEvent(e:ImageErrorEvent) {
console.log("图片加载错误",e.detail); //TODO tif打不出正确的错误日志
imageErrorEvent(e : ImageErrorEvent) {
console.log("图片加载错误", e.detail); //TODO tif打不出正确的错误日志
// 图片加载失败,加载本地占位图
e.target?.setAttribute('src', '/static/template/drop-card/dislike.png')
}
},
}
class ImageFormat {
format: string;
src: string;
format
: string;
src
: string;
constructor(format
: string, src
: string) {
constructor(format
: string, src
: string) {
this.format = format;
this.src = src;
}
...
...
pages/component/image/image-large.uvue
浏览文件 @
69f3716d
<template>
<view>
<
scroll-
view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-title">
...
...
@@ -10,7 +10,7 @@
<image class="image" mode="widthFix" :src="src" @load="load"></image>
</view>
</view>
</view>
</
scroll-
view>
</template>
<script>
...
...
pages/component/image/image-mode.uvue
浏览文件 @
69f3716d
<template>
<view>
<
scroll-
view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-title">
...
...
@@ -12,7 +12,7 @@
</view>
</view>
</view>
</view>
</
scroll-
view>
</template>
<script>
...
...
@@ -20,7 +20,8 @@
data() {
return {
title: 'image-mode',
data: [{
data: [
{
mode: 'scaleToFill',
description: '不保持纵横比缩放图片,使图片的宽高完全拉伸至填满 image 元素'
},
...
...
@@ -76,16 +77,16 @@
mode: 'heightFix',
description: '高度不变,宽度自动变化,保持原图宽高比不变'
}
] as Array
< ImageMode
>
] as Array
<ImageMode
>
}
}
}
class ImageMode {
mode: string;
description: string;
mode
: string;
description
: string;
constructor(mode
: string, description
: string) {
constructor(mode
: string, description
: string) {
this.mode = mode;
this.description = description;
}
...
...
pages/component/image/image-path.uvue
浏览文件 @
69f3716d
<template>
<view>
<
scroll-
view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-title">
...
...
@@ -12,7 +12,7 @@
</view>
</view>
</view>
</view>
</
scroll-
view>
</template>
<script>
...
...
@@ -26,12 +26,12 @@
description: '本地根路径'
},
{
src: '../../../static/test-image/logo.png',
//TODO
src: '../../../static/test-image/logo.png',
description: '本地相对路径'
},
{
src: 'logo.png', //TODO
description: '本地当前路径'
description: '本地当前路径
(暂不支持)
'
},
{
src: 'file:///storage/emulated/0/Android/data/io.dcloud.uniappx/apps/__UNI__4517034/www/static/test-image/logo.png',
...
...
@@ -48,37 +48,44 @@
{
src: 'https://request.dcloud.net.cn/api/http/contentType/image/png',
description: '正确网络路径'
},{
},
{
src: 'https://request.dcloud.net.cn/api/http/contentType/wrongImage/gif',
description: '错误网络格式,假gif实为jpeg'
},{
},
{
src: 'https://request.dcloud.net.cn/api/http/contentType/wrongImage/jpeg',
description: '错误网络格式,假jpg实为png'
},{
},
{
src: 'https://request.dcloud.net.cn/api/http/contentType/wrongImage/png',
description: '错误网络格式,假png实为gif'
},{
},
{
src: 'https://request.dcloud.net.cn/api/http/contentType/404',
description: '错误网络地址404接口'
},{
},
{
src: 'https://request.dcloud.net.cn/api/http/contentType/404.png',
description: '错误网络地址,不存在的图片'
}
,
] as Array
< ImagePath
>
}
] as Array
<ImagePath
>
}
},
methods: {
imageErrorEvent(e:ImageErrorEvent) {
console.log("图片加载错误",e.detail); //TODO
imageErrorEvent(e : ImageErrorEvent) {
console.log("图片加载错误", e.detail);
// 图片加载失败,加载本地占位图
e.target?.setAttribute('src', '/static/template/drop-card/dislike.png')
}
},
}
class ImagePath {
src: string;
description: string;
src
: string;
description
: string;
constructor(src
: string, description
: string) {
constructor(src
: string, description
: string) {
this.src = src;
this.description = description;
}
...
...
pages/component/image/image.uvue
浏览文件 @
69f3716d
...
...
@@ -14,9 +14,9 @@
</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="imageLarge">大图示例</button>
</view>
</view>
</view>
...
...
@@ -29,10 +29,10 @@
}
},
methods: {
error(event: ImageErrorEvent) {
error(event
: ImageErrorEvent) {
console.log(event.type, event.detail);
},
load(event: ImageLoadEvent) {
load(event
: ImageLoadEvent) {
console.log(event.type, event.detail);
},
imageFormat() {
...
...
@@ -49,11 +49,11 @@
uni.navigateTo({
url: '/pages/component/image/image-path'
});
},
imageLarge() {
uni.navigateTo({
url: '/pages/component/image/image-large'
});
},
imageLarge() {
uni.navigateTo({
url: '/pages/component/image/image-large'
});
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录