I have component Filter to find a title of movie from AllMovies.
When i filter, the movie list is not working properly
setFindMovies is method, filteredMovies is computed. It filter good, but when input in empty only shows firs element from regular array, not all array with elements
<FindMovie @find-movie="setFindMovies" ></FindMovie>
<TheMovie v-for="movie in filteredMovies" :key='movie.id' :id='movie.id' :title='movie.title' :year='movie.year' :description='movie.description'/>
setFindMovies(searchMovie){
this.activeMovies=searchMovie
console.log(searchMovie)
},
filteredMovies(){
let movies= this.$store.getters['movies/movies'];
let copyMovies=[]
if (this.activeMovies.title) {
console.log(this.activeMovies.title)
movies=movies.filter(movie=>{
let matchTitle=movie.title.includes(this.activeMovies.title)
if(matchTitle){
copyMovies.push({
title:movie.title,
year:movie.year,
description:movie.description,
id:movie.id
})
return movies=copyMovies
}
}
)
}
return movies