v-on:input
지시문에 매개 변수를 전달합니다 . 전달하지 않으면 메소드의 이벤트에 액세스 할 수 있습니다. 매개 변수를 함수에 전달할 때 여전히 이벤트에 액세스 할 수있는 방법이 있습니까? 내가 vue-router를 사용하고 있지는 않습니다.
이것은 매개 변수를 전달하지 않은 것입니다. 이벤트 객체에 액세스 할 수 있습니다
HTML
<input type="number" v-on:input="addToCart" min="0" placeholder="0">
자바 스크립트
methods: {
addToCart: function (event) {
// I need to access the element by using event.target
console.log('In addToCart')
console.log(event.target)
}
}
이것은 매개 변수를 전달할 때입니다. 이벤트 객체에 액세스 할 수 없습니다
HTML
<input type="number" v-on:input="addToCart(ticket.id)" min="0" placeholder="0">
자바 스크립트
methods: {
addToCart: function (id) {
// How can I access the element by using event
console.log('In addToCart')
console.log(id)
}
}
다음은 코드 스 니펫입니다. 문제가 발생할 수 있습니다
Property or method "event" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option