fix(SingleUpload.vue): 修复handleRemove的TypeScript编译报错问题

This commit is contained in:
郝先瑞
2022-01-23 00:46:07 +08:00
parent 506f5bf006
commit 1daa5c17ff

View File

@@ -65,7 +65,7 @@ const imgUrl = computed<string | null>({
*/ */
function uploadImage({file}: any) { function uploadImage({file}: any) {
uploadFile(file).then(response => { uploadFile(file).then(response => {
imgUrl.value = response.data imgUrl.value = response.data
}) })
} }
@@ -86,12 +86,14 @@ function handleExceed(files: UploadFile[]) {
/** /**
* 删除图片 * 删除图片
* *
* @param file * @param file
*/ */
function handleRemove(file: string) { function handleRemove(file: string | null) {
deleteFile(file) if (file) {
imgUrl.value = null // 这里会触发imgUrl的computed的set方法 deleteFile(file)
imgUrl.value = null // 这里会触发imgUrl的computed的set方法
}
} }
function handleBeforeUpload(file: any) { function handleBeforeUpload(file: any) {
@@ -111,7 +113,7 @@ function handleBeforeUpload(file: any) {
<style lang="scss" scoped> <style lang="scss" scoped>
.component-container{ .component-container {
.single-uploader { .single-uploader {
cursor: pointer; cursor: pointer;
position: relative; position: relative;
@@ -120,16 +122,19 @@ function handleBeforeUpload(file: any) {
&:hover { &:hover {
border-color: #409EFF; border-color: #409EFF;
} }
&-icon{
&-icon {
font-size: 28px; font-size: 28px;
color: #8c939d; color: #8c939d;
text-align: center; text-align: center;
} }
&-image{
&-image {
width: 146px; width: 146px;
height: 146px; height: 146px;
display: block; display: block;
} }
&-remove-icon { &-remove-icon {
font-size: 12px; font-size: 12px;
color: #ff4d51 !important; color: #ff4d51 !important;