fix: 修复上传组件图片显示和数据处理问题

修正上传组件中图片显示路径错误的问题,并正确处理上传接口返回的JSON数据
This commit is contained in:
feige996 2025-06-06 23:37:44 +08:00
parent a18880675b
commit 4bed7f2d13
2 changed files with 4 additions and 4 deletions

View File

@ -103,10 +103,10 @@ export default function useUpload<T extends TfileType>(options: TOptions<T> = {}
tempFilePath: tempFilePath, tempFilePath: tempFilePath,
formData, formData,
onSuccess: (res) => { onSuccess: (res) => {
data.value = res const { data: _data } = JSON.parse(res)
// https://oss.laf.run/ukw0y1-unibest/unibest.f5308ecd-06c3-463b-b3e0-5df08154c7f3.svg data.value = _data
// console.log('上传成功', res) // console.log('上传成功', res)
success?.(res) success?.(_data)
}, },
onError: (err) => { onError: (err) => {
error.value = err error.value = err

View File

@ -15,7 +15,7 @@
<view class="m-2">上传后返回的接口数据</view> <view class="m-2">上传后返回的接口数据</view>
<view class="m-2">{{ data }}</view> <view class="m-2">{{ data }}</view>
<view class="h-80 w-full"> <view class="h-80 w-full">
<image v-if="data" :src="data || data" mode="scaleToFill" /> <image v-if="data" :src="data.url" mode="scaleToFill" />
</view> </view>
</template> </template>
</view> </view>