下面的第3行,我意外地在我的控制台中找不到模块错误。这很奇怪,我的代码和文件结构看起来很好。
import React from 'react';
import UserList from '../containers/user-list';
import UserDetail from '../containers/user-detail';
require('../../scss/style.scss');
const App = () => (
<div>
<h2>Username List:</h2>
<UserList></UserList>
<hr />
<h2>User details</h2>
<UserDetail />
</div>
);
export default App;
答案 0 :(得分:0)
根据es5语法,你不能在第4行中这样做,你必须像这样编码:
如果你的app.js在组件中,那么它可以解决你的问题:
import React from 'react';
import UserList from '../containers/user-list';
import UserDetail from '../../containers/user-detail';
var style = require('../../../scss/style.scss');
const App = () => (
<div>
<h2>Username List:</h2>
<UserList></UserList>
<hr />
<h2>User details</h2>
<UserDetail />
</div>
);
export default App;