如何修复Firebase中TypeError: can't access property 'isRoot', location is undefined错误?
Firebase Storage + SvelteKit 报错:TypeError: can't access property "isRoot", location is undefined
TypeError: can't access property "isRoot", location is undefined
使用SvelteKit框架开发,已知location是浏览器对象,已经通过onMount调用、$app/environment检查确保在浏览器环境中执行代码,但仍然触发上述错误。定位到错误由以下调用listAll的代码导致:
listAll(filesRef).then((list)=>{ list.items.forEach(item=>{ files.push({ filetype:item.name.split(".").at(-1).toString(), name:item.name }); }); });
补充说明:files是一个对象数组,每个对象包含filetype(文件后缀)和name(文件名),最终会将这个数组渲染为页面列表。
完整堆栈跟踪信息:
list$2 requests.ts:182 list$1 reference.ts:406 listAllHelper reference.ts:361 listAll$1 reference.ts:343 listAll api.ts:257 instance +page.svelte:58 init index.mjs:2002 Page +page.svelte:791 createProxiedComponent svelte-hooks.js:341 ProxyComponent proxy.js:242 Proxy<+page> proxy.js:349 construct_svelte_component_dev index.mjs:2218 update root.svelte:274 update_slot_base index.mjs:98 update +layout.svelte:154 update index.mjs:1193 flush index.mjs:1160 promise callback*schedule_update index.mjs:1118 make_dirty index.mjs:1970 ctx index.mjs:2008 $$set root.svelte:581 get proxy.js:83 $set index.mjs:2109 key proxy.js:46 update client.js:320 navigate client.js:1077 goto client.js:182 goto client.js:1249 gotoNext +page.svelte:11 instance +page.svelte:18 registerStateListener auth_impl.ts:565 promise callback*registerStateListener auth_impl.ts:565 onAuthStateChanged auth_impl.ts:407 onAuthStateChanged index.ts:128 instance +page.svelte:17 run index.mjs:18 mount_component index.mjs:1939 flush index.mjs:1175 promise callback*schedule_update index.mjs:1118 make_dirty index.mjs:1970 ctx index.mjs:2008 $$set root.svelte:581 get proxy.js:83 $set index.mjs:2109 key proxy.js:46 update client.js:320 navigate client.js:1077 goto client.js:182 goto client.js:1249 default Goto.ts:3 instance +page.svelte:14 run index.mjs:18 mount_component index.mjs:1939 flush index.mjs:1175 init index.mjs:2034 Root root.svelte:633 createProxiedComponent svelte-hooks.js:341 ProxyComponent proxy.js:242 Proxy<Root> proxy.js:349 initialize client.js:374 _hydrate client.js:1630 start start.js:39 <anonymous> [page]:10039
内容的提问来源于stack exchange,提问作者Fighter178
相关产品推荐
相关产品推荐

