Commit 2db29a7f authored by shangbj's avatar shangbj

react

parent 525c1841
{
"presets":[
"react"
]
}
\ No newline at end of file
### babel-preset-react
安装新的以来后,再修改.babelrc配置文件加入React Presets
```javascript
"presets":[
"react"
]
```
\ No newline at end of file
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div id="app"></div>
<script src="./dist/bundle.js"></script>
</body>
</html>
\ No newline at end of file
import React,{ Component } from 'react';
import { render } from 'react-dom';
class Button extends Component{
render(){
return(
<h1>Hello,React</h1>
)
}
}
render(<Button/>, window.document.getElementById('app'));
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "3-6",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "webpack --mode development",
"build": "webpack --mode production"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"webpack": "^4.12.0",
"webpack-cli": "^3.0.3"
},
"dependencies": {
"react": "^16.4.0",
"react-dom": "^16.4.0"
}
}
const path = require("path");
module.exports = {
entry:"./main.js",
output:{
filename:'bundle.js',
path: path.resolve(__dirname,"./dist")
},
module:{
rules:[
{
test:/\.js$/,
use:['babel-loader'],
//排除
exclude:path.resolve(__dirname,'node_modules')
}
]
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment