1👍
✅
The v-on
needs the event name, and does not need another $emit
unless you intend to re-emit the event to a grandparent component. See the Vue event handling docs. It should be
<Student
v-on:addStudent="receiveStudent"
/>
Or short-hand
<Student
@addStudent="receiveStudent"
/>
Other errors that need to be corrected:
-
{{ students }}
is called text interpolation and goes in between tags, not inside tags. Something like<div>{{ students }}</div>
would make more sense if you want to display the entire array of students. -
You are not sending any actual props down to the Student. Based on Student.vue having props "name" and "program" you would pass down these props from the Parent like so:
<Student
v-for="student in students"
:key="student"
:name="student.name"
:program="student.program"
@addStudent="receiveStudent"
>
Source:stackexchange.com