添加上传图片两张
This commit is contained in:
parent
22a0f69217
commit
c8ac1c82a5
|
@ -9,7 +9,7 @@
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<a-button class="btn-success" @click="selectFile">{{ btnLabel }}</a-button>
|
<a-button class="btn-success" @click="selectFile">{{ btnLabel }}</a-button>
|
||||||
<input :id="idFile" type="file" style="display: none" ref="fileInput" />
|
<input :id="id" type="file" style="display: none" ref="fileInput" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ const props = withDefaults(
|
||||||
width?: string | number;
|
width?: string | number;
|
||||||
height?: string | number;
|
height?: string | number;
|
||||||
btnLabel?: string;
|
btnLabel?: string;
|
||||||
idFile?: string | any;
|
id?: string | any;
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
parentDir: "",
|
parentDir: "",
|
||||||
|
@ -43,7 +43,7 @@ const props = withDefaults(
|
||||||
width: "150px",
|
width: "150px",
|
||||||
height: "150px",
|
height: "150px",
|
||||||
btnLabel: "选择图片",
|
btnLabel: "选择图片",
|
||||||
idFile: "myFileInput",
|
id: "myFileInput",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ const uploadUrl = ref();
|
||||||
const fileInput = ref(null);
|
const fileInput = ref(null);
|
||||||
|
|
||||||
const selectFile = () => {
|
const selectFile = () => {
|
||||||
document.getElementById(props.idFile)?.click();
|
document.getElementById(props.id)?.click();
|
||||||
};
|
};
|
||||||
|
|
||||||
async function inputFileListener(this: HTMLInputElement) {
|
async function inputFileListener(this: HTMLInputElement) {
|
||||||
|
@ -107,13 +107,13 @@ const fileDelete = () => {
|
||||||
};
|
};
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
document
|
document
|
||||||
.getElementById(props.idFile)
|
.getElementById(props.id)
|
||||||
?.addEventListener("change", inputFileListener);
|
?.addEventListener("change", inputFileListener);
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
document
|
document
|
||||||
.getElementById(props.idFile)
|
.getElementById(props.id)
|
||||||
?.removeEventListener("change", inputFileListener);
|
?.removeEventListener("change", inputFileListener);
|
||||||
});
|
});
|
||||||
defineExpose({ fileDelete });
|
defineExpose({ fileDelete });
|
||||||
|
|
Loading…
Reference in New Issue