完成项目基本结构

This commit is contained in:
wzhqwq 2021-07-17 23:36:16 +08:00
父節點 c4f95a0ead
當前提交 111a0149a9
共有 8 個檔案被更改,包括 54 行新增37 行删除

查看文件

@ -1,11 +1,13 @@
{
"name": "react-app-model",
"name": "in-my-heart",
"version": "0.1.0",
"private": true,
"dependencies": {
"cra-template": "1.1.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-dropzone": "^11.3.4",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3"
},
"scripts": {

查看文件

@ -1,24 +1,14 @@
import logo from './logo.svg';
import './App.css';
import { HashRouter, Route } from 'react-router-dom';
import { AppContainer } from './index/index';
import { UploadContainer } from './upload/upload';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
<HashRouter>
<Route path="/" component={AppContainer} />
<Route path="/upload" component={UploadContainer} />
</HashRouter>
);
}

查看文件

@ -2,7 +2,6 @@ import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
ReactDOM.render(
<React.StrictMode>
@ -10,8 +9,3 @@ ReactDOM.render(
</React.StrictMode>,
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
reportWebVitals();

0
src/index/index.css Normal file
查看文件

13
src/index/index.js Normal file
查看文件

@ -0,0 +1,13 @@
import { Component } from 'react';
import './index.css';
// copilot抄来的模板
export class AppContainer extends Component {
render() {
return (
<div className="App">
{this.props.children}
</div>
);
}
}

查看文件

@ -1,13 +0,0 @@
const reportWebVitals = onPerfEntry => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;

0
src/upload/upload.css Normal file
查看文件

31
src/upload/upload.js Normal file
查看文件

@ -0,0 +1,31 @@
import { Component } from 'react';
import './upload.css';
// copilot抄来的模板
export class UploadContainer extends Component {
constructor(props) {
super(props);
this.state = {
files: []
};
}
handleChange = (e) => {
const files = e.target.files;
this.setState({ files });
};
render() {
return (
<div className="upload-container">
<input type="file" onChange={this.handleChange} />
{this.state.files.map((file, i) => (
<div key={i} className="upload-item">
<img className="upload-item-img" src={file.preview} />
<p className="upload-item-name">{file.name}</p>
</div>
))}
</div>
);
}
}