vue3 事件响应问题

 3 months ago
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.

V2EX  ›  问与答

vue3 事件响应问题

  fangwenxue · 1 小时 42 分钟前 · 141 次点击
    const uploadInput = ref(null)
    const clickUpload = (e) => {
      if (uploadInput.value) {
        console.log(uploadInput.value) # 每次触发都打印了 2 次
    const fileChange = (e) => {
      console.log(e) # 第二次选择文件没有触发事件

    <div class="container content">
        <div class="upload-box" @click="clickUpload">
        	<input type="file" class="hidden" accept="image/*" ref="uploadInput" @change="fileChange">

第二次选择文件为什么没有触发事件 ?

About Joyk

Aggregate valuable and interesting links.
Joyk means Joy of geeK