在反应中考虑以下组件:
import React from 'react';
export default class MainContainner extends React.component{
render() {
console.log("I am here");
return (
<dev> Salman is here </dev>
);
}
}
我在第一行遇到了错误
ERROR in ./js/mainContainner
Module parse failed: C:\Users\Salman\WebstormProjects\hw2\js\mainContainner Line 1: Unexpected token
You may need an appropriate loader to handle this file type.
| import React from 'react';
|
| export default class MainContainner extends React.component{
我确信我有合适的装载机:
"dependencies": {
"babel-cli": "^6.5.1",
"babel-preset-es2015": "^6.5.0",
"babel-loader": "^6.2.1",
"babel-preset-react": "^6.3.13",
"babelify": "^7.2.0"
我也见过this,和 和webpack结构很酷
module.exports={
entry: './js/main.js',
output:{
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /.js?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
}
]
},
devServer:{
port:3000
}
};
问题是什么?