Shopify 资产未加载
我尝试使用 URL 过滤器从我的 Shopify 资产中包含一个 JavaScript 文件(名为 StoreLocator.js),如 Shopify 文档中所述(请参阅 https://shopify.dev/api/liquid/filters/url-filters)。
首先,我将 JavaScript 文件上传到 asset 文件夹。我在调试过程中注意到,可以通过以下 URL 访问上传的 JavaScript 文件:
https://cdn.shopify.com/s/files/1/0551/8009/9636/t/6/assets/StoreLocator.js
我能够调试这个,因为我使用了相同的JavaScript 文件和之前项目中的相同 URL 过滤器,效果很好。因此我可以看到,Shopify 使用此 URL 来加载 JavaScript 文件。
但是,通过在新项目中使用以下 URL 过滤器。
{{ 'StoreLocator.js' | asset_url | script_tag }}
它生成以下不正确的 URL(请注意 /t/6
与 /t9
部分。
https://cdn.shopify.com/s/files/1/0551/8009/9636/t/9/assets/StoreLocator.js
不幸的是,我找不到任何有关 URL 的文档 会很有趣。
在本例中,了解 URL 从 /t/6
更改为 /t9
的原因 观点到正确的网址?
I am trying to include a JavaScript file (named StoreLocator.js) from my Shopify assets by using the URL filters as explained in the Shopify documentation (see https://shopify.dev/api/liquid/filters/url-filters).
First of all, I uploaded the JavaScript file to the assets folder. I noticed during debugging that the uploaded JavaScript file is accessible under the following URL:
https://cdn.shopify.com/s/files/1/0551/8009/9636/t/6/assets/StoreLocator.js
I was able to debug this, because I used the same JavaScript file and the same URL filter in a previous project and it worked just fine. Therefore I could see, that Shopify uses this URL to load the JavaScript file.
However, by using the following URL-filter in the new project.
{{ 'StoreLocator.js' | asset_url | script_tag }}
it generates the following URL which is incorrect (note the part /t/6
vs /t9
.
https://cdn.shopify.com/s/files/1/0551/8009/9636/t/9/assets/StoreLocator.js
Unfortunately I could not find any documentation about the URLs that the Shopify CDN generates. In the present case it would be interesting to know why the URL changed from /t/6
to /t9
.
Can someone explain why the URL filter does not point to the correct URL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试此代码,它会起作用: -
确保您的 StoreLocator.js 文件存在于 Assets 文件夹中
使用此后,您必须在“查看页面源代码”中检查此 url,然后单击此 url 并在浏览器和任何代码编辑器中检查 url 代码
Try this code it will work:-
Make sure your StoreLocator.js file is present in Assets folder
After using this you have to check this url in 'view page source' and click this url and check url code in browser and in any code editor