File tree Expand file tree Collapse file tree 1 file changed +28
-19
lines changed Expand file tree Collapse file tree 1 file changed +28
-19
lines changed Original file line number Diff line number Diff line change 1212 :on-error =" onError"
1313 >
1414 <template #default >
15- <el-image v-if =" modelValue" :src =" modelValue" />
16- <el-icon v-if =" modelValue" class =" single-upload__delete-btn" @click.stop =" handleDelete" >
17- <CircleCloseFilled />
18- </el-icon >
19- <el-icon v-else class =" single-upload__add-btn" >
20- <Plus />
21- </el-icon >
15+ <template v-if =" modelValue " >
16+ <el-image
17+ class =" single-upload__image"
18+ :src =" modelValue"
19+ :preview-src-list =" [modelValue]"
20+ @click.stop =" handlePreview"
21+ />
22+ <el-icon class =" single-upload__delete-btn" @click.stop =" handleDelete" >
23+ <CircleCloseFilled />
24+ </el-icon >
25+ </template >
26+ <template v-else >
27+ <el-icon >
28+ <Plus />
29+ </el-icon >
30+ </template >
2231 </template >
2332 </el-upload >
2433</template >
@@ -138,6 +147,13 @@ function handleUpload(options: UploadRequestOptions) {
138147 });
139148}
140149
150+ /**
151+ * 预览图片
152+ */
153+ function handlePreview() {
154+ console .log (" 预览图片,停止冒泡" );
155+ }
156+
141157/**
142158 * 删除图片
143159 */
@@ -166,21 +182,14 @@ const onError = (error: any) => {
166182
167183<style scoped lang="scss">
168184:deep(.el-upload--picture-card ) {
169- width : v-bind (" props.style.width" );
170- height : v-bind (" props.style.height" );
185+ position : relative ;
186+ width : v-bind (" props.style.width ?? '150px'" );
187+ height : v-bind (" props.style.height ?? '150px'" );
171188}
172189
173190.single-upload {
174- position : relative ;
175- width : v-bind (" props.style.width" );
176- height : v-bind (" props.style.height" );
177- overflow : hidden ;
178- cursor : pointer ;
179- border : 1px var (--el-border-color ) solid ;
180- border-radius : 5px ;
181-
182- & :hover {
183- border-color : var (--el-color-primary );
191+ & __image {
192+ border-radius : 6px ;
184193 }
185194
186195 & __delete-btn {
You can’t perform that action at this time.
0 commit comments