简体   繁体   中英

Is there a way to call a javascript file from the assets folder, to a snippet on Shopify?

I have created the code for a finance calculator using a mixture of HTML and Javascript. I had originally created it all in the same liquid file; but now I want to call the Javascript file into the snippet. This was because the Javascript was previously showing in the "Inspect Element: Elements" tab.

I had tried adding a piece of liquid code at the top of the snippet, however it has proved unsuccessful.

{{ 'finance-calculator.js' | asset_url | script_tag }}

When I removed the Javascript from the liquid file, I tried using the liquid code above, however it had broke the calculator and stopped it from making calculations.

您可以在您的液体页面中编写以下代码- <script type="text/javascript" src="{{ 'finance-calculator.js' | asset_url }}"></script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM