视图:
<view>
<view>tempSrc:</view>
<image :src="tempSrc" :webp="true"></image>
<view>imageSrc:</view>
<image :src="imageSrc" :webp="true" ></image>
</view>
js:
var downloadTask = uni.downloadFile({
url:"http://dingyue.ws.126.net/2020/0331/558792e9j00q80s3p006dc000rs017dm.jpg",
success: (res) => {
console.log("downloadFile success:",res);
this.tempSrc = res.tempFilePath;
uni.saveFile({
tempFilePath: res.tempFilePath,
fail:(e) => {
console.log("saveFile fail:",e);
},
success: (res) => {
console.log("saveFile success:", res);
this.imageSrc = res.savedFilePath;
},
});
}
});