Skip to content

Commit e6a9dd0

Browse files
committed
fix: 个人中心头像为空时不能修改
1 parent e8dce93 commit e6a9dd0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/components/Cropper/src/CropperAvatar.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<div class="user-info-head" @click="open()">
33
<img v-if="sourceValue" :src="sourceValue" alt="avatar" class="img-circle img-lg" />
4+
<img v-if="!sourceValue" :src="avatar" alt="avatar" class="img-circle img-lg" />
45
<el-button v-if="showBtn" :class="`${prefixCls}-upload-btn`" @click="open()">
56
{{ btnText ? btnText : t('cropper.selectImage') }}
67
</el-button>
@@ -17,6 +18,7 @@ import { useDesign } from '@/hooks/web/useDesign'
1718
import { propTypes } from '@/utils/propTypes'
1819
import { useI18n } from 'vue-i18n'
1920
import CopperModal from './CopperModal.vue'
21+
import avatar from '@/assets/imgs/avatar.jpg'
2022
2123
defineOptions({ name: 'CropperAvatar' })
2224

src/views/Profile/components/UserAvatar.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
ref="cropperRef"
55
:btnProps="{ preIcon: 'ant-design:cloud-upload-outlined' }"
66
:showBtn="false"
7-
:value="avatar"
7+
:value="img"
88
width="120px"
99
@change="handelUpload"
1010
/>
@@ -13,15 +13,13 @@
1313
<script lang="ts" setup>
1414
import { propTypes } from '@/utils/propTypes'
1515
import { uploadAvatar } from '@/api/system/user/profile'
16+
import { CropperAvatar } from '@/components/Cropper'
1617
1718
defineOptions({ name: 'UserAvatar' })
1819
19-
const props = defineProps({
20+
defineProps({
2021
img: propTypes.string.def('')
2122
})
22-
const avatar = computed(() => {
23-
return props.img
24-
})
2523
2624
const cropperRef = ref()
2725
const handelUpload = async ({ data }) => {

0 commit comments

Comments
 (0)