①创建项目
npx degit dcloudio/uni-preset-vue#vite-ts my-vue3-project
②页面
<template>
<view class="content">
<image class="logo" :src="current" @tap="previewImage(current)" />
</view>
</template>
<script setup lang="ts">
const current =
"https://vip.hangshida-pd.com:8021/images/2022/07/14/562ac469-ac7b-4105-acc4-9c49e789712b.png";
const previewImage = (current: string) => {
const urls = [
"https://vip.hangshida-pd.com:8021/images/2022/07/14/562ac469-ac7b-4105-acc4-9c49e789712b.png",
"https://vip.hangshida-pd.com:8021/images/2022/07/14/c329c7c4-5ed4-436d-8381-3f146b2467cc.png",
"https://vip.hangshida-pd.com:8021/images/2022/07/14/4216a664-4995-4583-b311-bd70cdf01e70.png",
];
uni.previewImage({
current,
urls,
success: (result) => {
console.log("result: ", result);
},
fail: (error) => {
console.log("error: ", error);
},
});
};
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
</style>
z***@163.com
遇到了同样的问题,图片存在unicloud的云存储上的,直接使用image可以展示,使用uni.previewImage无法展示,直接使用浏览器也能打开图片
2022-11-20 00:58
DCloud_UNI_WZF
回复 z***@163.com: 测试微信小程序原生开发是否有问题?如确认框架问题,提供测试工程
2022-11-20 17:53