You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a <h1> containing the text "Star Wars: The Last Jedi (2017)"
a <h2> containing the text "Action, Adventure, Fantasy"
a <p> containing the text "Rey develops her newly discovered abilities with the guidance of Luke Skywalker, who is unsettled by the strength of her powers. Meanwhile, the Resistance prepares to do battle with the First Order."
in App, bind "item" to "movie" on the <movie-item> element
<!-- App.vue --><movie-item:item="movie" />
in Appdata(), add another object "movie2" with the following properties:
// App.vue{title: 'Black Swan',year: 2010,genre: 'Drama, Thriller',plot: 'A committed dancer wins the lead role in a production of Tchaikovskys \"Swan Lake\" only to find herself struggling to maintain her sanity.',poster: 'https://images-na.ssl-images-amazon.com/images/I/615yWgAir2L._SY500_.jpg'}
in App<template>, add another <movie-item> bound to "movie2"
check the console for errors, you'll have a few surprises! ;-)
add class "mb-2" to App<div>
12. A bit of responsivness (+)
display 2 cards per row on large screens:
in App, wrap the movie cards in a <div class="row">
in MovieItem<template>, wrap everything with a <div class="col-lg-6 px-2> div
13. Conditional rendering: v-if & v-else (+++)
in MovieItem, add a data() property named "isEditing", initially set to false
wrap the <textarea> and the word count <div> with a <template v-if="isEditing">
add a <div v-else> immediately after the above <template> and show the comment prefixed by "Your comment: "
if the comment is empty, display "No comment yet."
change the "Clear comment" button's text to "Edit/Save comment", remove its old behavior and make it toggle the "isEditing" state
14. HTML rendering: v-html (++)
define a "formattedComment" computed that returns "No comment yet." if the comment is empty, and "Your comment: <b>...</b>" otherwise
set the previous <div v-else> content to the computed:
extract the parts of MovieItem<template> and <script> that have to do with showing and editing of the comment to a new MovieComment component
hint: create the new MovieComment component, move the comment part of the MovieItem<template> to it, import, register and render a <movie-comment /> in place of the moved layout, and try to move / fix things around until you get rid of all the console errors and the previous functionality is restored
in MovieComment, define a "comment" prop, bind it from MovieItem
try to edit the comment and check the console for errors ;-)
15.1. Refactor MovieComment to handle v-model: v-model on Vue components & watchers (++++)
hint: <movie-comment v-model="item.comment"> is shorthand for <movie-comment :value="item.comment" @input=item.comment = $event">, where $event is a special Vue property set to the input event's payload
in MovieComment, define "value" prop, move the "comment" prop to data() and set its initial value to the "value" prop
in Appdata(), replace "movie" and "movie2" with a "movies" array having the following content:
// App.vueexportdefault{
...
data(){return{movies: [{id: 1,title: 'Star Wars: The Last Jedi',year: 2017,genre: 'Action, Adventure, Fantasy',plot:
'Rey develops her newly discovered abilities with the guidance of Luke Skywalker, who is unsettled by the strength of her powers. Meanwhile, the Resistance prepares to do battle with the First Order.',poster:
'https://images-na.ssl-images-amazon.com/images/I/51ih4cPagFL.jpg',comment: '',},{id: 2,title: 'Black Swan',year: 2010,genre: 'Drama, Thriller',plot:
'A committed dancer wins the lead role in a production of Tchaikovskys "Swan Lake" only to find herself struggling to maintain her sanity.',poster:
'https://images-na.ssl-images-amazon.com/images/I/615yWgAir2L._SY500_.jpg',comment: '',},{id: 3,title: 'Fight Club',year: 1999,genre: 'Drama',plot:
'An insomniac office worker, looking for a way to change his life, crosses paths with a devil-may-care soapmaker, forming an underground fight club that evolves into something much, much more.',poster:
'https://images-na.ssl-images-amazon.com/images/I/51iOANjtCQL.jpg',comment: '',},{id: 4,title: 'The Godfather: Part II',year: 1974,genre: 'Crime, Drama',plot:
'The early life and career of Vito Corleone in 1920s New York City is portrayed, while his son, Michael, expands and tightens his grip on the family crime syndicate.',poster:
'https://images-na.ssl-images-amazon.com/images/I/41V2AB34KCL.jpg',comment: '',},],}}}
in App<template>, replace the two static <movie-item>s with a dynamic <movie-item> list, iterating over movies:
<!-- App.vue --><movie-listv-for="movie in movies" :item="movie" :key="movie.id" />