-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebComponent.html
More file actions
38 lines (35 loc) · 1.07 KB
/
WebComponent.html
File metadata and controls
38 lines (35 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!-- Lit 라이브러리를 쓰면 문법을 간단하게 쓸 수 있다 -->
<!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>Document</title>
</head>
<body>
<custom-input name="123"></custom-input>
<script>
class meMake extends HTMLElement {
connectedCallback() {
this.render();
}
render() {
let 라벨 = document.createElement("label");
라벨.innerHTML = "이름을 입력하세요";
this.appendChild(라벨);
let 인풋 = document.createElement("input");
this.appendChild(인풋);
}
static get observedAttributes() {
return ["name"]; //[]가 바뀌는지 확인 (react-hook기능)
//바뀌면 재렌더링
}
attributeChangedCallback() {
this.render();
}
}
customElements.define("custom-input", meMake);
</script>
</body>
</html>