【发布时间】:2018-01-14 23:10:07
【问题描述】:
我在一个应用程序中使用 VuexFire,就像在我的组件中的 https://github.com/posva/vuexfire 一样,我有类似的行
computed: Vuex.mapGetters(['todos']),
created() {
this.$store.dispatch('setTodosRef', todosRef)
},
这很好用,除非我还有一些计算方法,在这种情况下我不知道该怎么做。我试过这样的事情:
computed: Vuex.mapGetters(['todos']),
computed() {
amethod: { return 1 }
},
created() {
this.$store.dispatch('setTodosRef', todosRef)
},
和
computed() {
amethod: { return 1 }
},
created() {
...Vuex.mapGetters(['todos'])
this.$store.dispatch('setTodosRef', todosRef)
},
但是这些以及我尝试过的其他事情显然被误导了,因为它们不起作用(即该方法无法使用来自 firebase 的数据。
正确的做法是什么?
【问题讨论】: