【发布时间】:2017-08-16 17:13:52
【问题描述】:
谁能在 react-js 上下文中向我解释以下场景: 我使用 webpack 并使用预设“babel-preset-env”和“react”。
在一个文件的顶部,我导入了一个 config.json,我尝试使用开发人员工具和调试器语句进行检查。
console.log 按预期记录一组对象。如果我进入 developer-tools js-console 并输入 CONFIG,我会收到 Uncaught ReferenceError: CONFIG is not defined。
import React, { Component } from 'react';
import CONFIG from './config.json';
class MyComponent extends Component{
render(){
//this statement logs as expected
console.log(CONFIG);
// the debugger stops execution, but when I enter CONFIG in the
// dev-tools Console I get the error: Uncaught ReferenceError:
// CONFIG is not defined
debugger;
}
}
非常感谢任何帮助。
【问题讨论】:
标签: javascript reactjs