如何将依赖导入到 Vuex 操作中?
How to import dependency into Vuex actions?
将函数导入 Vuex 操作的正确方法是什么?我问是因为在尝试将 Firebase doc()
导入我的操作代码时出现以下 eslint 错误:
'doc' is declared but its value is never read.ts(6133)
'doc' is defined but never used.eslintno-unused-vars
(alias) function doc(firestore: FirebaseFirestore, path: string, ...pathSegments: string[]): DocumentReference<DocumentData> (+2 overloads)
import doc
这是 actions.js
代码:
import { doc } from "firebase/firestore"
import {db} from '~/plugins/firebase.js'
export default {
async getUserProfile({ commit }, authUser) {
try {
const docRef = doc(db, 'users', authUser.uid) // <----trying to use `doc()` here but get that eslint error
....
}
....
}
为什么我不能将 doc()
函数导入到 getUserProfile()
操作中?
已更新截图:
最后,这是由于 doc
在代码后面被(重新)声明 造成的。因此,为什么 ESlint 抱怨未使用的变量。
将函数导入 Vuex 操作的正确方法是什么?我问是因为在尝试将 Firebase doc()
导入我的操作代码时出现以下 eslint 错误:
'doc' is declared but its value is never read.ts(6133)
'doc' is defined but never used.eslintno-unused-vars
(alias) function doc(firestore: FirebaseFirestore, path: string, ...pathSegments: string[]): DocumentReference<DocumentData> (+2 overloads)
import doc
这是 actions.js
代码:
import { doc } from "firebase/firestore"
import {db} from '~/plugins/firebase.js'
export default {
async getUserProfile({ commit }, authUser) {
try {
const docRef = doc(db, 'users', authUser.uid) // <----trying to use `doc()` here but get that eslint error
....
}
....
}
为什么我不能将 doc()
函数导入到 getUserProfile()
操作中?
已更新截图:
最后,这是由于 doc
在代码后面被(重新)声明