Shopify 结帐 UI 扩展错误“窗口未定义”。尝试导入外部模块时

问题描述 投票:0回答:1

我们正在努力将应用程序功能扩展到新的 Shopify checkout ui 扩展中,我正在尝试将外部模块导入到我的

scr/Checkout.tsx
文件中,当我运行代码时,它会抛出以下错误。

I'm not sure how i could import the module and have it run since its the main dependency for the app syntax to run!
: 
ReferenceError: window is not defined at Object.<anonymous> (https://assets.prd.shoprunner.io/@shoprunner/shopping@1/es6/index.js:1:10825) at Object.<anonymous> (https://assets.prd.shoprunner.io/@shoprunner/shopping@1/es6/index.js:1:10858) at l (https://assets.prd.shoprunner.io/@shoprunner/shopping@1/es6/index.js:1:9983) at Module.<anonymous> (https://assets.prd.shoprunner.io/@shoprunner/shopping@1/es6/index.js:1:32749) at l (https://assets.prd.shoprunner.io/@shoprunner/shopping@1/es6/index.js:1:9983) at https://assets.prd.shoprunner.io/@shoprunner/shopping@1/es6/index.js:1:10771 at https://assets.prd.shoprunner.io/@shoprunner/shopping@1/es6/index.js:1:10781 at https://assets.prd.shoprunner.io/@shoprunner/shopping@1/es6/index.js:1:9848 at https://assets.prd.shoprunner.io/@shoprunner/shopping@1/es6/index.js:1:9853 at https://assets.prd.shoprunner.io/@shoprunner/shopping@1/es6/index.js:127:7213
message
: 
"window is not defined"
stack

我已经在

network_access = true
中设置了我的``[extensions.capability]
shopify.ui.extension.toml
。我还认为这是因为窗口对象在我的代码运行后加载,所以我创建了一个延迟函数,但它仍然没有任何帮助。

 const loadModule = async () => {
        const module = import('the url link goes here ');
        return module;
    };
shopify shopify-app remix shopify-api shopify-api-node
1个回答
0
投票

你曾经让它发挥作用吗?我有同样的问题。窗口或文档直到页面加载之后才被定义,并且 DOMContentLoaded 没有任何帮助,并且 setTimeout 花费太长时间并且超时。

© www.soinside.com 2019 - 2024. All rights reserved.