The parameter e is passed but cannot be obtained~

In Vue 3, $eventevent objects can be accessed using . But in your code example, you can't $eventget the event object directly through ebecause you didn't explicitly pass it as a parameter.

To get the event object e, you can use inline functions in JavaScript to pass additional parameters. As follows:

<template>
  <input type="file" @change="(e) => uploadImage(e, item, index)" />
</template>

<script>
export default {
  methods: {
    uploadImage(event, item, index) {
      // 在这里访问事件对象 event
      console.log(event);
    }
  }
}
</script>

In this example, we use the inline function (e) => uploadImage(e, item, index)for binding @changethe event and epass the event object as the first parameter to uploadImagethe method. In this way, the event object can be accessed in the method and printed out in the console for verification.

Guess you like

Origin blog.csdn.net/weixin_55209970/article/details/131702254