Showing A List of Movies
To populate the list
component with a list of movies from App
, the parent component, send a request to your server for the data.
Fetch the Movies
To obtain a list of the movies:
Import
axios
, a library for making Ajax requests:Add the Ajax logic to the
created
lifecycle method of theApp
component:The logic sends a
get
request withaxios
to a URL stored inthis.url
. When a payload returns, it setsthis.movies
to the value of the payload.Define
movies
andurl
in the model:
Render VideoList
VideoList
Now import the VideoList
component and render its element.
Import
VideoList
:Specify the child in the component:
Render to the DOM immediately below the
VideoPlayer
component:
Handle the Selected Videos
Afterwards, the choose-movie
event calls the updatePlayer
method if the event is triggered. Therefore, add updatePlayer
to the methods
object:
updatePlayer
sets the value of movie
, which triggers the watch in VideoPlayer
, causing a change in the trailer that is playing.
So far, so good:
You can also select a movie to see its trailer:
Last updated