![](/img/trans.png)
[英]How to add a module to my SystemJs config file so I can import it in angular
[英]How can I import the config file properly?
我正在研究导入/导出和模块。 我能够导入 jQuery 文件,但在尝试导入配置文件时出现错误。
这是我得到的错误:
config:1
Failed to load resource: the server responded with a status of 404 (Not Found)
(我想使用配置文件,因为它可以帮助我管理用于开发和生产的 api 令牌。)
我正在尝试将配置文件导入 jquery 文件:
以下是配置文件中的内容:
export default {
WEATHER_API_ENDPOINT: `https://api.weatherbit.io/v2.0/forecast/daily?`,
API_KEY: process.env.API_KEY,
}
这是 jquery 文件的一部分:
import config from './config'
let weatherBaseUrl = config.WEATHER_API_ENDPOINT;
let weatherApiKey = config.API_KEY;
...
export default function handleJquery() {
$(handleExploreApp);
}
以下是主文件中的内容:
import handleJquery from './jquery.js'
handleJquery()
主文件链接到 html 文件中,如下所示:
<script type="module" src="main.js"></script>
(webpack 会对此有所帮助吗?)
尝试这个
const Config = { WEATHER_API_ENDPOINT: `https://api.weatherbit.io/v2.0/forecast/daily?`, API_KEY: process.env.API_KEY, } export default Config
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.