尝试使用 vuexfire 进行 Firebase 绑定,文档状态为插入以下绑定操作
const setTodosRef = firebaseAction(({ bindFirebaseRef, unbindFirebaseRef }, { ref }) => {
// bunding will automatically unbind any previously bound ref so you
// don't need to unbind before binding over an existing bound key
bindFirebaseRef('todos', ref)
// it is possible to unbind a bound key at any time
unbindFirebaseRef('todos')
})
在我的商店 root.js 中,所有操作都使用以下模式编写
/**
* Import Dependency
*/
import * as types from './mutation_types'
import i18n from '@/locales'
import * as firebase from 'firebase'
import { firebaseMutations, firebaseAction } from 'vuexfire'
setTodosRef ( ) {
bindFirebaseRef('todos', ref)
unbindFirebaseRef('todos')
}
如何将参数传递给函数?为了打电话
this.$store.dispatch('setTodosRef', db.ref('todos'))
setTodosRef (firebaseAction(({ bindFirebaseRef, unbindFirebaseRef }, { ref })) { ... }
不工作...
Syntax Error: Unexpected token, expected "," (119:29)
感谢您的反馈
更新
我使用删除了语法错误
setTodosRef: firebaseAction(({ bindFirebaseRef, unbindFirebaseRef }, ref) => {
bindFirebaseRef('todos', ref)
unbindFirebaseRef('todos')
})
但我不确定这是否正确......?