Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
e8729a499a | |||
1a1cd5d8d3 | |||
b15f09c27c | |||
b051c59e9e | |||
653fc7b09d |
12
README.md
12
README.md
@@ -1,15 +1,5 @@
|
|||||||
# umi project
|
|
||||||
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
Install dependencies,
|
http://localhost:3000/api/users
|
||||||
|
|
||||||
```bash
|
|
||||||
$ yarn
|
|
||||||
```
|
|
||||||
|
|
||||||
Start the dev server,
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ yarn start
|
|
||||||
```
|
|
||||||
|
@@ -1,13 +1,10 @@
|
|||||||
import { defineConfig } from 'umi';
|
import { defineConfig } from 'umi';
|
||||||
|
import routes from './routes'
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
nodeModulesTransform: {
|
nodeModulesTransform: {
|
||||||
type: 'none', // all 慢 兼容好
|
type: 'none', // all 慢 兼容好
|
||||||
},
|
},
|
||||||
routes: [
|
routes,
|
||||||
{ path: '/', component: '@/pages/index' },
|
|
||||||
{ path: '/about', component: '@/pages/about' },
|
|
||||||
],
|
|
||||||
fastRefresh: {},
|
fastRefresh: {},
|
||||||
history: {
|
history: {
|
||||||
type: 'browser'
|
type: 'browser'
|
||||||
@@ -21,6 +18,12 @@ export default defineConfig({
|
|||||||
dynamicImport: {}, // 按需加载
|
dynamicImport: {}, // 按需加载
|
||||||
mountElementId: 'root', // 指定 reactapp 渲染到元素的根元素 id
|
mountElementId: 'root', // 指定 reactapp 渲染到元素的根元素 id
|
||||||
|
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: 'https://127.0.0.1:8989'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
// 主题
|
// 主题
|
||||||
theme: {
|
theme: {
|
||||||
'@primary-color': 'red',
|
'@primary-color': 'red',
|
||||||
|
4
config/routes.ts
Normal file
4
config/routes.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export default [
|
||||||
|
{ path: '/', component: '@/pages/index' },
|
||||||
|
{ path: '/about', component: '@/pages/about' },
|
||||||
|
]
|
7
mock/api.ts
Normal file
7
mock/api.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export default {
|
||||||
|
// 支持值为 Object 和 Array
|
||||||
|
'GET /api/users': { users: [1, 2] },
|
||||||
|
|
||||||
|
// GET 可忽略
|
||||||
|
'/api/users/1': { id: 1 },
|
||||||
|
}
|
13
src/components/Box.tsx
Normal file
13
src/components/Box.tsx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import {useState} from "react";
|
||||||
|
import { Button } from 'antd'
|
||||||
|
export function BoxDiv(){
|
||||||
|
let [number, setNumber] = useState(0)
|
||||||
|
function clickHandler(){
|
||||||
|
setNumber(number+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (<div>
|
||||||
|
<h1>Box-{number}</h1>
|
||||||
|
<Button onClick={ clickHandler }>+</Button>
|
||||||
|
</div>)
|
||||||
|
}
|
@@ -1,16 +1,13 @@
|
|||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
import { Button } from 'antd'
|
import { Button } from 'antd'
|
||||||
import { Button as ButtonMobileV2 } from 'antd-mobile-v2'
|
import { BoxDiv } from '@/components/Box'
|
||||||
import { Button as ButtonMobileV5 } from 'antd-mobile'
|
import { request } from 'umi'
|
||||||
export default function IndexPage() {
|
export default function IndexPage() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h1 className={styles.title}>Page index</h1>
|
<h1 className={styles.title}>Page index</h1>
|
||||||
<Button type={"primary"}>Click</Button>
|
<Button type={"primary"}>Click</Button>
|
||||||
<ButtonMobileV2>Click</ButtonMobileV2>
|
<BoxDiv></BoxDiv>
|
||||||
<ButtonMobileV5>Click</ButtonMobileV5>
|
|
||||||
<img src={ require('@/assets/user.jpg') } alt="" draggable={false} />
|
|
||||||
<img src="/user.jpg" alt="" draggable={false}/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user