我正在使用谷歌的CDN,并试图加载我自己的AMD模块使用他们的装载机.我知道我在做错事,但我被卡住了.有任何想法吗?
<script src="https://ajax.googleapis.com/ajax/libs/dojo/1.7.0/dojo/dojo.js" type="text/javascript" data-dojo-config="async:true,parSEOnLoad:true"></script> <script type="text/javascript"> require(["dojo/_base/kernel","dojo/_base/loader","dojo/parser"],function(dojo){ dojo.registerModulePath("pgGallery","http://127.0.0.1:8080/js"); }); require(["pgGallery/Message"],function(m){ m.success("foo"); }); </script>
解决方法
我在这里找到了如何做:
http://dojotoolkit.org/reference-guide/quickstart/cross-domain.html在“使用CDN与本地模块”下.
该页面的示例:
<script type="text/javascript"> var dojoConfig = { async: true,packages: [ { name: "my",location: "/absolute/path/to/local/modules" } ] }; </script> <!-- Bootstrap Dojo From Google's CDN --> <!-- removing the protocol from src url auto detects if current page is served via http or https and also loads the dojo resources from matching protocol --> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/dojo/1.7.1/dojo/dojo.js"> </script> <script type="text/javascript"> require(["my/FooModule"],function(FooModule){ // ... }); </script>