简体   繁体   English

shopify应用(python)未捕获ReferenceError:未定义require

[英]shopify app (python)Uncaught ReferenceError: require is not defined

with the Shopify API for python 使用适用于python的Shopify API

i am able to place the script tag in the (client's) store . 我能够将脚本标记放置在(客户端)商店中。

Problem is i am having two script tags among one is a Require.js. 问题是我有两个脚本标签,其中一个是Require.js。

store page's source code (client's store) 商店页面的源代码(客户商店)

var urls = ["myjsfilewithrequire.js? shop=store.myshopify.com","mysecondfile.js?shop=store.myshopify.com"];

this is what gets loaded . 这就是加载的东西。

How can i make sure that one js is loaded completed (requre.js) before rest files are loaded . 我如何确保在加载其余文件之前已完成一个js的加载(requre.js)。

Is this way of doing is right ? 这种做法是对的吗? ( I have not tired yet ) (我还不累)

var imported = document.createElement('script');
imported.src = 'myscriptfile.js';
document.head.appendChild(imported);


function load_data(){
    undone = true;
    while(typeof(window.myscriptfile.data)=="object" && undone){

any loop();}

I guess there must be any better way to do it . 我想一定有更好的方法可以做到这一点。

I had this same problem, and solved it by using almond . 我遇到了同样的问题,并使用杏仁解决了。

It's by the maintainer of RequireJS, and is a light-weight AMD loader. 它由RequireJS的维护者提供,是轻型AMD加载器。 It can be compiled in to your optimized JS, and then included (as a ScriptTag) in your client's Shopify site. 可以将其编译到优化的JS中,然后(作为ScriptTag)包含在客户端的Shopify站点中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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