Javascript firebase存储无法读取未定义的属性“child”

Javascript firebase存储无法读取未定义的属性“child”,javascript,firebase,firebase-storage,Javascript,Firebase,Firebase Storage,您好,我目前正在跟踪从firebase存储获取图像,并根据登录的用户ID在我的html中显示它 index.html: <script src="scripts/config.js"></script> <script src="scripts/auth.js"></script> 但我目前遇到以下错误: auth.js:11未捕获类型错误:无法读取的属性“child” 未定义 我确信我在child中输入的参数在控制台日志中有一个值: conso

您好,我目前正在跟踪从firebase存储获取图像,并根据登录的用户ID在我的html中显示它

index.html:

<script src="scripts/config.js"></script>
<script src="scripts/auth.js"></script>
但我目前遇到以下错误:

auth.js:11未捕获类型错误:无法读取的属性“child” 未定义

我确信我在child中输入的参数在控制台日志中有一个值:

console.log(`test/${user.uid}/profile-pic.jpg`);
使用登录的用户ID显示当前字符串:

测试/dtrNGt9usCSqwV86BfKnw6SjWHb2/profile-pic.jpg

我仔细检查了文档,看看是否写错了什么,但似乎没有发现任何错误

我还检查firebase存储中文件的路径,它确实在测试文件夹中


希望有人能告诉我我的代码有什么问题

哦,我发现了,我认为storageRef是一个函数,但它是对文件夹的引用。我把它改成这个,现在它工作了:

storage.ref(`test/${user.uid}/profilepic.jpg`).getDownloadURL().then(function(url) {
   $("#pic").attr("src", url);
}).catch(function(error) {
    console.error(error);
);
未定义的是storage.storageRef,而不是字符串。你能试着记录它吗?@crossx它返回的是未定义的,为什么?我定义了常量存储=firebase.storage;在我的config.js中,我在auth.js中使用了storage.storageRef,而auth.js在html的config.js下
console.log(`test/${user.uid}/profile-pic.jpg`);
storage.ref(`test/${user.uid}/profilepic.jpg`).getDownloadURL().then(function(url) {
   $("#pic").attr("src", url);
}).catch(function(error) {
    console.error(error);
);