我想将图像上传到 firebase storage,版本 9。我有 firestore 的工作代码,但我一生都无法理解有关上传的 firebase 文档,以及如何使其适用于 Vue (这也需要导入REF 函数)。
我的问题是:如何在 Vue 中导入 ref 函数,以及如何导入和使用 firebase firestore 中的 ref 函数?
这就是我所拥有的。用 .value 包装 Firebase ref 感觉不对,但我只是将它放在那里以克服 vue 错误。
vue 组件代码片段:<-- 这有效
if (imageFile.value) {
await uploadImage(imageFile.value);
console.log("image:" + url.value);
}
Run Code Online (Sandbox Code Playgroud)
useStorage.js <--这是尝试从 Firebase 8 转换为 9 时一切都崩溃的地方。它是 vue Ref 函数吗?
import { ref } from "vue";
import { projectStorage } from "../firebase/config";
import { uploadBytesResumable, getDownloadURL } from
"@firebase/storage";
const useStorage = () => {
const error = …Run Code Online (Sandbox Code Playgroud)