![](/style/images/good.png)
1
![](/style/images/bad.png)
vue3 事件响应问题
source link: https://www.v2ex.com/t/884214
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
setup(){
const uploadInput = ref(null)
const clickUpload = (e) => {
if (uploadInput.value) {
console.log(uploadInput.value) # 每次触发都打印了 2 次
uploadInput.value.click()
}
}
const fileChange = (e) => {
console.log(e) # 第二次选择文件没有触发事件
}
}
<template>
<div class="container content">
<div class="upload-box" @click="clickUpload">
<input type="file" class="hidden" accept="image/*" ref="uploadInput" @change="fileChange">
</div>
</div>
</template>
第二次选择文件为什么没有触发事件 ?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK