51 lines
934 B
Vue
51 lines
934 B
Vue
<template>
|
|
<view class="image-upload-page">
|
|
<view class="content">
|
|
<!-- 使用图片上传组件 -->
|
|
<image-uploader
|
|
ref="uploader"
|
|
:height="'150rpx'"
|
|
:width="'150rpx'"
|
|
@error="handleUploadError"
|
|
@success="handleUploadSuccess"
|
|
/>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
methods: {
|
|
// 上传成功回调
|
|
handleUploadSuccess(result) {
|
|
console.log('图片上传成功:', result.url)
|
|
|
|
uni.showToast({
|
|
title: '上传成功',
|
|
icon: 'success',
|
|
})
|
|
},
|
|
|
|
// 上传失败回调
|
|
handleUploadError(error) {
|
|
console.error('图片上传失败:', error)
|
|
uni.showToast({
|
|
title: '上传失败',
|
|
icon: 'none',
|
|
})
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.image-upload-page {
|
|
min-height: 100vh;
|
|
background: #f5f5f5;
|
|
|
|
.content {
|
|
padding: 30rpx;
|
|
}
|
|
}
|
|
</style>
|