3 Commits

Author SHA1 Message Date
1a1cd5d8d3 feat: init 2023-10-01 01:37:49 +08:00
b15f09c27c feat: init 2023-10-01 01:36:39 +08:00
b051c59e9e feat: init 2023-10-01 01:26:04 +08:00
6 changed files with 31 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
# 默认全局
src/global.less
http://localhost:3000/api/users

View File

@@ -1,13 +1,10 @@
import { defineConfig } from 'umi';
import routes from './routes'
export default defineConfig({
nodeModulesTransform: {
type: 'none', // all 慢 兼容好
},
routes: [
{ path: '/', component: '@/pages/index' },
{ path: '/about', component: '@/pages/about' },
],
routes,
fastRefresh: {},
history: {
type: 'browser'

4
config/routes.ts Normal file
View File

@@ -0,0 +1,4 @@
export default [
{ path: '/', component: '@/pages/index' },
{ path: '/about', component: '@/pages/about' },
]

7
mock/api.ts Normal file
View 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
View 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>)
}

View File

@@ -1,10 +1,12 @@
import styles from './index.less';
import { Button } from 'antd'
import { BoxDiv } from '@/components/Box'
export default function IndexPage() {
return (
<div>
<h1 className={styles.title}>Page index</h1>
<Button type={"primary"}>Click</Button>
<BoxDiv></BoxDiv>
</div>
);
}