페이지 라우팅 기본설정
This commit is contained in:
parent
0fe0655bc3
commit
7f271ec0e7
38
src/App.tsx
38
src/App.tsx
@ -1,34 +1,16 @@
|
|||||||
import { useState } from 'react'
|
import React from 'react'
|
||||||
import reactLogo from './assets/react.svg'
|
import { BrowserRouter, Routes, Route } from 'react-router-dom'
|
||||||
import viteLogo from '/vite.svg'
|
import MainPage from '@pages/index'
|
||||||
import './App.css'
|
import AboutPage from '@pages/about'
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [count, setCount] = useState(0)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<BrowserRouter>
|
||||||
<div>
|
<Routes>
|
||||||
<a href="https://vite.dev" target="_blank">
|
<Route index path='/' element={<MainPage />}></Route>
|
||||||
<img src={viteLogo} className="logo" alt="Vite logo" />
|
<Route index path='/about' element={<AboutPage />}></Route>
|
||||||
</a>
|
</Routes>
|
||||||
<a href="https://react.dev" target="_blank">
|
</BrowserRouter>
|
||||||
<img src={reactLogo} className="logo react" alt="React logo" />
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<h1>Vite + React</h1>
|
|
||||||
<div className="card">
|
|
||||||
<button onClick={() => setCount((count) => count + 1)}>
|
|
||||||
count is {count}
|
|
||||||
</button>
|
|
||||||
<p>
|
|
||||||
Edit <code>src/App.tsx</code> and save to test HMR
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<p className="read-the-docs">
|
|
||||||
Click on the Vite and React logos to learn more
|
|
||||||
</p>
|
|
||||||
</>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { StrictMode } from 'react'
|
import { StrictMode } from 'react'
|
||||||
import { createRoot } from 'react-dom/client'
|
import { createRoot } from 'react-dom/client'
|
||||||
import './index.css'
|
// import './index.css'
|
||||||
import App from './App.tsx'
|
import App from './App.tsx'
|
||||||
|
|
||||||
createRoot(document.getElementById('root')!).render(
|
createRoot(document.getElementById('root')!).render(
|
||||||
|
|||||||
9
src/pages/about.tsx
Normal file
9
src/pages/about.tsx
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
function index() {
|
||||||
|
return (
|
||||||
|
<div>about 페이지입니다.</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default index
|
||||||
9
src/pages/index.tsx
Normal file
9
src/pages/index.tsx
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
function index() {
|
||||||
|
return (
|
||||||
|
<div>메인 홈페이지 파일입니다.</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default index
|
||||||
@ -30,13 +30,12 @@
|
|||||||
"@/*": ["src/*"],
|
"@/*": ["src/*"],
|
||||||
"@components/*": ["src/components/*"],
|
"@components/*": ["src/components/*"],
|
||||||
"@assets/*": ["src/assets/*"],
|
"@assets/*": ["src/assets/*"],
|
||||||
"@/components*": ["src/components*"],
|
"@pages/*": ["src/pages/*"],
|
||||||
"@/pages/*": ["src/pages/*"],
|
"@types/*": ["src/types/*"],
|
||||||
"@/types*": ["src/types*"],
|
"@recoil/*": ["src/recoil/*"],
|
||||||
"@/recoil/*": ["src/recoil/*"],
|
"@apis/*": ["src/apis/*"],
|
||||||
"@/apis/*": ["src/apis/*"],
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["src"],
|
"include": ["src"],
|
||||||
"references": [{"path": "./tsconfig.node.json"}]
|
// "references": [{"path": "./tsconfig.node.json"}]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,3 @@
|
|||||||
{
|
{
|
||||||
"files": [],
|
"extends": "./tsconfig.app.json"
|
||||||
"references": [
|
|
||||||
{ "path": "./tsconfig.app.json" },
|
|
||||||
{ "path": "./tsconfig.node.json" }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user