[英]system.js import from another folder
I have public/index.html
and src/app.js
. 我有
public/index.html
和src/app.js
Inside index.html
i have the following system.js
call to load app.js
在
index.html
内部,我有以下system.js
调用来加载app.js
<script>System.import('../src/app');</script>
It fails with the following error: 它失败并出现以下错误:
GET https://registry.jspm.io/src/app.js 404 (Not Found)
What should be the syntax to load files from another folder? 从另一个文件夹加载文件的语法应该是什么?
You may have forgotten a few other things: 您可能忘记了其他一些事情:
1) you must import system.js (auto installed with jspm init) 1)你必须导入system.js (使用jspm init自动安装)
2) you must include your config.js
(auto installed with jspm init) 2)你必须包括你的
config.js
(使用jspm init自动安装)
<script src="../jspm_packages/system.js"></script>
<script src="../config.js"></script>
<script>
System.import('client/index').catch(console.log.bind(console));
</script>
3) see how my import says 'client/index' it means my folder structure looks like this: 3)看看我的导入如何表示“客户端/索引”,这意味着我的文件夹结构如下所示:
4) Now lastly the config.js
has base path (this is from where your system.import will start; regardless of where the index.html file is.) 4)现在最后
config.js
有基本路径(这是你的system.import将从哪里开始;无论index.html文件在哪里。)
System.config({
"baseURL": "/",
"transpiler": "traceur",
"paths": {
"*": "*.js",
"github:*": "jspm_packages/github/*.js",
"npm:*": "jspm_packages/npm/*.js"
}
});
one of these should fix everything. 其中一个应该修复一切。 I think it's #2
我认为这是#2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.