我正在尝试拆分 Twitch 机器人的凭据,以便将其放入 .gitignore 中,这样它就不会上传到 GitHub。我正在导出这个:
凭证/twitchCredentials.js
let identity: {
username: 'instakbot',
password: 'testerino'
};
export default identity;
我尝试将其导入到组件/Chat/ChatContainer中
import identity from 'credentials/twitchCredentials';
console.log(identity);
但这会在控制台中返回未定义...当我尝试导入聊天组件时,它完全正常工作
import {ChatMessage} from 'components/Chat';
components/与credentials/处于同一级别,因此它不会导致任何问题...我使用的是 webpack 1.13.2。
最佳答案
正如伯吉评论的那样:
let identity: { is a syntax error, it should be let identity = { (and even better, be const)
关于javascript - 导入对象未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39858734/