cinema/vue.riot

67 lines
1.3 KiB
Plaintext
Raw Normal View History

2022-04-01 22:49:14 +02:00
<vue>
<div id="conteneur" >
<compofilm each={ film in state.films.results } v_film="{ film }" v_setVisiSetter="{ addVisibilitySetter }" v_setFilmSetter="{ addSetter }">
</compofilm> <!--Refuse de s'update-->
</div>
<script>
export default {
state: {
loading: false,
error: null,
films: [],
visible: true,
setters: [],
film_setters: [],
genres_names: [],
genres_ids: []
},
reset() {
this.update({
loading: false,
error: null,
films: [],
visible: true,
setters: [],
film_setters: [],
genres_names: [],
genres_ids: []
})
},
async onBeforeMount(props,state){
await new Promise(r => setTimeout(r, 200));
props.t_setSetters(this.setFilms,this.setVisibilite);
this.update();
},
setFilms(data){
this.state.films=data;
i = 0;
for(setter of this.state.film_setters){
setter(data.results[i++]);
}
},
setVisibilite(visible){
this.state.visible=visible;
for(setter of this.state.setters){
setter(visible);
}
},
addVisibilitySetter(setter){
this.state.setters.push(setter);
},
addSetter(setter){
this.state.film_setters.push(setter);
}
}
</script>
<style>
compofilm{
display: inline-block;
width: 22%;
margin: 1%;
}
</style>
</vue>