提交 59d95c58 编写于 作者: W wanganxp

修正之前图片显示不全的问题

上级 57846b94
...@@ -4,15 +4,13 @@ ...@@ -4,15 +4,13 @@
<!-- #endif --> <!-- #endif -->
<view> <view>
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt"> <view>
<view v-if="imageSrc" class="image-container"> <view v-if="imageSrc">
<image class="img" :src="imageSrc" mode="center" /> <image class="img" :src="imageSrc" mode="aspectFit" />
</view> </view>
<view v-else style="margin-top: 50px"> <view v-else style="margin: 10px;">
<text class="uni-hello-text">点击按钮下载服务端示例图片(下载网络文件到本地临时目录)</text> <text class="uni-hello-text">点击按钮下载服务端示例图片(下载网络文件到本地临时目录)</text>
<view class="uni-btn-v"> <button type="primary" @tap="downloadImage">下载</button>
<button type="primary" @tap="downloadImage">下载</button>
</view>
</view> </view>
</view> </view>
</view> </view>
...@@ -34,7 +32,7 @@ ...@@ -34,7 +32,7 @@
onLoad() { onLoad() {
}, },
onUnload() { onUnload() {
this.imageSrc = ''; // this.imageSrc = '';
uni.hideLoading(); uni.hideLoading();
this.task?.abort(); this.task?.abort();
}, },
...@@ -47,7 +45,7 @@ ...@@ -47,7 +45,7 @@
this.task = uni.downloadFile({ this.task = uni.downloadFile({
url: "https://web-assets.dcloud.net.cn/unidoc/zh/uni-app.png", url: "https://web-assets.dcloud.net.cn/unidoc/zh/uni-app.png",
success: (res) => { success: (res) => {
console.log('downloadFile success, res is', res) console.log('downloadFile success, res is', res.tempFilePath)
self.imageSrc = res.tempFilePath; self.imageSrc = res.tempFilePath;
uni.hideLoading(); uni.hideLoading();
}, },
...@@ -78,14 +76,6 @@ ...@@ -78,14 +76,6 @@
<style> <style>
.img { .img {
width: 500rpx;
height: 500rpx;
margin: 0 auto; margin: 0 auto;
} }
</style>
.image-container {
display: flex;
justify-content: center;
align-items: center;
}
</style>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册