Vue.js 如何在子组件中使用父组件传递的函数
我有一位家长,他叫孩子:Vue.js 如何在子组件中使用父组件传递的函数,vue.js,Vue.js,我有一位家长,他叫孩子: <select-school-type placeholder="Filter par type école" @selected="getSchools"></select-school-type> 我看到console.log消息的值正确 但是,如何使用正确的值调用getSchools方法?我做了很多事情都没有成功 我是Vue初学者。您需要将值传递到$emit方法: this.$emit('selec
<select-school-type placeholder="Filter par type école" @selected="getSchools"></select-school-type>
我看到console.log消息的值正确
但是,如何使用正确的值调用getSchools方法?我做了很多事情都没有成功
我是Vue初学者。您需要将值传递到
$emit
方法:
this.$emit('selected', event.target.value)
在子组件中,必须将参数传递给发出的字符串
onChange(事件){
此.$emit('selected',event.target.value)
}
onChange(event){
console.log(event.target.value)
this.$emit('selected')
}
this.$emit('selected', event.target.value)