mirror of
https://github.com/certd/certd.git
synced 2026-05-15 12:37:30 +08:00
28 lines
674 B
Vue
28 lines
674 B
Vue
|
|
<template>
|
||
|
|
<div class="file-input">
|
||
|
|
<a-button :type="type" @click="onClick">{{ text }}</a-button> {{ fileName }}
|
||
|
|
<div class="hidden">
|
||
|
|
<input ref="fileInputRef" type="file" @change="onFileChange" />
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script lang="ts" setup>
|
||
|
|
import { ref, defineEmits, defineProps } from "vue";
|
||
|
|
const fileInputRef = ref<HTMLInputElement | null>(null);
|
||
|
|
|
||
|
|
const props = defineProps<{
|
||
|
|
text: string;
|
||
|
|
type: string;
|
||
|
|
}>();
|
||
|
|
const fileName = ref("");
|
||
|
|
const emit = defineEmits(["change"]);
|
||
|
|
function onClick() {
|
||
|
|
fileInputRef.value.click();
|
||
|
|
}
|
||
|
|
function onFileChange(e: any) {
|
||
|
|
fileName.value = e.target.files[0].name;
|
||
|
|
emit("change", e);
|
||
|
|
}
|
||
|
|
</script>
|