am从我的数据库中获取数据并显示它,但没有显示
我的状态
state: {
movies:[],
items:'',
},
我的吸气剂
getMovies:state=>{
return state.items
}
变异
setMovies: state => {
let items = [];
db.collection('movies').orderBy('name').onSnapshot((snapshot) => {
items = [];
snapshot.forEach((doc) => {
items.push({ id: doc.id, name: doc.data().name })
});
state.items = items
})
}
动作
setMovies: context => {
context.commit('setMovies')
}
显示
<div v-for="item in this.$store.getters.getMovies" :key="item.name">
{{ item.name }}<br /><br /><small >Delete</small>
<hr />
</div>
脚本
<script>
export default {
name: 'app',
beforeCreate: function () {
this.$store.dispatch('setMovies')
},
components: {
}
}
</script>
数据似乎没有显示