使用react和redux时找不到模块错误

时间:2016-12-25 11:18:05

标签: javascript reactjs redux

下面的第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;

enter image description here

enter image description here

1 个答案:

答案 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;