-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yinpeng.wyp
committed
May 20, 2021
1 parent
bd311b0
commit 3e3ac75
Showing
23 changed files
with
14,027 additions
and
16 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
</body> | ||
</html> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "react-webpack", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"dev": "webpack serve --config webpack.dev.config.js", | ||
"build": "webpack" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@babel/core": "^7.0.1", | ||
"@babel/preset-env": "^7.0.0", | ||
"@babel/preset-react": "^7.0.0", | ||
"babel-loader": "^8.0.2", | ||
"eslint": "^5.5.0", | ||
"eslint-config-standard": "^12.0.0", | ||
"eslint-plugin-html": "^4.0.5", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-node": "^7.0.1", | ||
"eslint-plugin-promise": "^4.0.1", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"html-webpack-plugin": "^5.2.0", | ||
"webpack": "^5.24.3", | ||
"webpack-cdn-plugin": "^3.3.1", | ||
"webpack-cli": "^4.5.0", | ||
"webpack-dev-server": "^3.1.8", | ||
"webpack-merge": "^4.1.4" | ||
}, | ||
"dependencies": { | ||
"axios": "^0.21.1", | ||
"react": "^16.5.0", | ||
"react-dom": "^16.5.0", | ||
"react-router-dom": "^5.2.0" | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React, { useState } from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
function PageB() { | ||
const [ip, setIP] =useState('') | ||
import('axios').then(module=>{ | ||
module.default.get('https://hanma.alibaba-inc.com/oapi/util/get_internal_ip').then(res=>{ | ||
console.log(res) | ||
setIP(res.data.data.ip) | ||
}) | ||
}) | ||
return ( | ||
<div className="PageB"> | ||
PageB | ||
ip: {ip} | ||
|
||
</div> | ||
); | ||
} | ||
|
||
export default PageB; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
import { BrowserRouter as Router, Switch, Route, Link } from 'react-router-dom' | ||
import App from './App.jsx'; | ||
import PageB from './PageB' | ||
|
||
ReactDOM.render( | ||
<Router> | ||
<div> | ||
<nav> | ||
<ul> | ||
<li> | ||
<Link to="/">Home</Link> | ||
</li> | ||
<li> | ||
<Link to="/pageB">pageB</Link> | ||
</li> | ||
</ul> | ||
</nav> | ||
|
||
{/* A <Switch> looks through its children <Route>s and | ||
renders the first one that matches the current URL. */} | ||
<Switch> | ||
<Route path="/pageB"> | ||
<PageB /> | ||
</Route> | ||
<Route path="/"> | ||
<App /> | ||
</Route> | ||
</Switch> | ||
</div> | ||
</Router>, | ||
document.getElementById('root') | ||
); | ||
|
||
// If you want to start measuring performance in your app, pass a function | ||
// to log results (for example: reportWebVitals(console.log)) | ||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
const path = require('path') | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const WebpackCdnPlugin = require('webpack-cdn-plugin'); | ||
|
||
module.exports = { | ||
mode:'production', | ||
output: { | ||
path: path.resolve(__dirname, './dist'), | ||
filename: 'main.js', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /.jsx?$/, | ||
use: { | ||
loader: 'babel-loader', | ||
options: { | ||
presets: ['@babel/preset-env', '@babel/preset-react'] | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
plugins:[ | ||
new HtmlWebpackPlugin( | ||
{ | ||
filename: 'index.html', | ||
template: './index.html', | ||
} | ||
), | ||
new WebpackCdnPlugin( | ||
{ | ||
optimize: true, | ||
modules: [ | ||
{ name: 'axios', var: 'axios', prodUrl: 'https://g.alicdn.com/code/lib/axios/0.21.1/axios.min.js' }, | ||
] | ||
} | ||
) | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const merge = require('webpack-merge') | ||
const webpackBase = require('./webpack.config') | ||
module.exports = merge(webpackBase, { | ||
mode: 'development', | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
"extends": "standard", | ||
"plugins":["html", "react"], | ||
"rules":{ | ||
// 解决react报错 | ||
"react/jsx-uses-react":2, | ||
// 解决var App 报错 | ||
"react/jsx-uses-vars":2, | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
|
||
presets: [['@babel/preset-env', {targets: {node: 'current'}}], | ||
'@babel/preset-react', | ||
// '@babel/preset-typescript', | ||
], | ||
|
||
}; |
File renamed without changes.
Oops, something went wrong.