我得到這個錯誤陣營 - ES6 - 意外標記
ERROR in ./src/components/Header/index.js
Module build failed: SyntaxError: C:/Users/Gil/Documents/Projects/ecommerce/src/components/Header/index.js: Unexpected token (16:7)
14 | }
15 |
> 16 | test =() => {
| ^
17 | console.log('pass!');
18 | };
19 |
,我認爲它與ES6的東西,但我不知道,反正這是我的配置
webpack.config.js
loaders: [
{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ },
{ test: /\.jsx$/, loader: 'babel-loader', exclude: /node_modules/ },
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader'
},...
的package.json
"devDependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"react-scripts": "1.0.7"
所以我的問題是,當我嘗試使用arrow function
我得到這個錯誤,我需要一個額外的配置還是我做錯了什麼?
*「當我嘗試使用箭頭功能我得到這個錯誤」 *的問題是不帶箭頭的功能。它的作用是'test = ...;'。 –
謝謝@FelixKling,我只是標記了它。 – Gil