I try to emit value change in new Vue Composition Api, like this
<template>
<select
@change="handleChange()"
>
<option value="text">Text</option>
<option value="image">Image</option>
</select>
</template>
<script lang="ts">
export default {
name: "Select",
setup(props, { emit }) {
const handleChange = (event: any) => {
emit("customChange", event.target.value);
};
return {
handleChange,
};
},
};
<script/>
Return
Cannot read properties of undefined (reading ‘target’)
So i think is the are some error. Somebody see the error?
>Solution :
You are calling handleChange without arguments. Either do
@change="handleChange"
or
@change="handleChange($event)"
or
@change="e => handleChange(e)"
Any of them will pass the event as first parameter to your handler function.