π 곡λΆνλ μ§μ§μνμΉ΄λ μ²μμ΄μ§?
Typescript λ‘ ννμ΄μ§ λ§λ€μ΄λ³΄κΈ° λ³Έλ¬Έ
π©π» λ°±μλ(Back-End)/Typescript
Typescript λ‘ ννμ΄μ§ λ§λ€μ΄λ³΄κΈ°
μ§μ§μνμΉ΄ 2023. 5. 31. 18:41728x90
λ°μν
<λ³Έ λΈλ‘κ·Έλ memi Dev μ μ νλΈλ₯Ό μ°Έκ³ ν΄μ 곡λΆνλ©° μμ±νμμ΅λλ€ :-)>
=> αα ¦αα ΅αα ΄ αα ’αα ‘α―αα ‘α¨αα 22 ννμ΄μ§ αα ‘α«αα ³α―αα ₯αα ©αα ΅
π§Έ Typescript λ‘ ννμ΄μ§ λ§λ€μ΄λ³΄κΈ°
π© index.ts
import express from "express"
import birds from "./routes/birds"
import dogs from "./routes/dogs"
import fs from "node:fs/promises"
const app = express()
app.use("/", express.static("public"))
app.use("/birds", birds)
app.use("/dogs", dogs)
app.listen(4000)
π© public/spa.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SPA</title>
</head>
<body>
<div>
<a onclick = "change('home')">home</a>
<a onclick = "change('dog')">dog</a>
<a onclick = "change('bird')">bird</a>
</div>
<div>
<img id = "img" src="https://loremflickr.com/320/240/home" />
</div>
<p id = "content">home</p>
<script>
function change (name) {
console.log(name)
document.getElementById("content").innerHTML = name
document.getElementById("img").src = "https://loremflickr.com/320/240/" + name
}
</script>
</body>
</html>
728x90
λ°μν
'π©βπ» λ°±μλ(Back-End) > Typescript' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
Typescriptλ‘ express λ²μ μ html αα ©αα ’αα ΅ (0) | 2023.05.31 |
---|---|
Typescript λ‘ express αα ₯α¨αα αΌαα ‘αα ΅ (0) | 2023.05.31 |
Typescript λ‘ socket μ¬μ©νκΈ° (server, client) (0) | 2023.05.29 |
TypeScript μ²μ μ¬μ©ν΄λ³΄κΈ° (μ€μΉνκΈ°, κΈ°λ³Έμ μΈ νμ λͺ λ Ή) (0) | 2023.05.20 |
Comments