无法读取未定义的属性(读取 'path')Firebase ref 函数冲突
Cannot read properties of undefined (reading 'path') Firebase ref function conflict
错误:
未捕获(承诺)TypeError:无法读取未定义的属性(读取 'path')
根据我的测试,
import { getStorage, ref, uploadBytesResumable, getDownloadURL }
from "https://www.gstatic.com/firebasejs/9.1.1/firebase-storage.js";
import { getDatabase, set, child, get, update, remove }
from "https://www.gstatic.com/firebasejs/9.1.1/firebase-database.js";
const realdb = getDatabase();
错误是因为 ref( ) 来自 firebase-storage 的函数不同于 ref( ) 来自 firebase 数据库
但是我只能导入其中一个函数,怎么办?
要保存 downloadURL,我需要 (firebase-storage) 和 (firebase-database)。
您可以像这样重命名其中一个导入:
import { getStorage, ref as storageRef } from "https://www.gstatic.com/firebasejs/9.1.1/firebase-storage.js";
然后确保您在代码中使用 storageRef()
而不是 ref()
进行存储。
错误:
未捕获(承诺)TypeError:无法读取未定义的属性(读取 'path')
根据我的测试,
import { getStorage, ref, uploadBytesResumable, getDownloadURL }
from "https://www.gstatic.com/firebasejs/9.1.1/firebase-storage.js";
import { getDatabase, set, child, get, update, remove }
from "https://www.gstatic.com/firebasejs/9.1.1/firebase-database.js";
const realdb = getDatabase();
错误是因为 ref( ) 来自 firebase-storage 的函数不同于 ref( ) 来自 firebase 数据库
但是我只能导入其中一个函数,怎么办? 要保存 downloadURL,我需要 (firebase-storage) 和 (firebase-database)。
您可以像这样重命名其中一个导入:
import { getStorage, ref as storageRef } from "https://www.gstatic.com/firebasejs/9.1.1/firebase-storage.js";
然后确保您在代码中使用 storageRef()
而不是 ref()
进行存储。