<button type="button" @click="greet">count is {{ count }}</button>
function greet(event) {
if (event) {
console.log(event)
console.log(event.target)
console.log(event.target.tagName)
}
}
很明显没传参数,但是获取到了相应的值
<input type="text" @change="handleChange" />
function handleChange(event) {
console.log(event)
console.log(event.target)
console.log(event.target.value)
}
在vue3中
<Input ref="test" @input="geet"></Input>
const test = ref()
const geet = () => {
console.log(test)
console.log(test.value)
console.log(test.value.value)
console.log(test.value.offsetHeight)
}