我想打印在 20 点之后或当天开始的时间段的电影。无论哪种方式,我都无法让它发挥作用。
组件数据结构:
day:"2017-06-08T18:34:27.211Z"
movies:Array[8]
0:Object
Description:"orphan the becomes a famous magician "
id:1
movieName:"Harry Potter "
time_session:Array[3]
0:Object
id:1
pivot:Object
time:"2017-06-14 00:00:00"
1:Object
2:Object
1:Object
2:Object
3:Object
4:Object
Run Code Online (Sandbox Code Playgroud)
模板:
<template>
<div>
<li v-for="movie in filteration(movies)">{{movie.movieName}}</li>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
如何过滤电影,以便显示的电影取决于同一对象中的时间会话?
这是我尝试过的:
<script>
export default{
data() {
return {
movies:[],
day:moment()
}
},
mounted(){
axios.get("/fa")
.then(response => this.movies = response.data);
},
methods:{
filteration(movie){
return movie.filter(this.time);
},
time(movie){
return moment(movie.time_session.time).hour() > 20;
// return moment(movie.time_session.time).isSame(this.day,'day');
}
}
}
</script>
Run Code Online (Sandbox Code Playgroud)