1
@longtap
是 Vue/uni-app 中的事件监听器,用于监听长按事件。当用户在对应元素上长按时,触发绑定的事件处理函数。
<image src="https:xxx.jpg" @longtap="upImg"></image>
方法
upImg() {
const imgUrl = 'https:xxx.jpg';
uni.downloadFile({
url: imgUrl,
success: (res) => {
if (res.statusCode === 200) {
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: function() {
uni.showToast({
title: "保存成功",
duration: 2000
});
},
fail: function() {
uni.showToast({
title: "保存失败,请稍后重试",
icon: "none"
});
}
});
} else {
uni.showToast({
title: "下载失败,请稍后重试",
icon: "none"
});
}
},
fail: function() {
uni.showToast({
title: "下载失败,请稍后重试",
icon: "none"
});
}
});
}