-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
39 lines (36 loc) · 1.12 KB
/
index.html
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
39
<!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>Vue is Awesome</title>
</head>
<body>
<h1>Vue is awesome!</h1>
<h2>$ <span id="total">0</span></h2>
<button onclick="product.quantity--">-</button>
<button onclick="product.quantity++">+</button>
<input
type="color"
value="#ff69b4"
oninput="product.color = this.value"
/>
<script src="reactivity.js"></script>
<script>
const product = reactive({
price: 15,
quantity: 2,
color: 'hotpink',
})
let total = 0
effect(() => {
total = product.price * product.quantity
document.getElementById('total').innerText = total
})
effect(() => {
document.body.style.backgroundColor = product.color
})
</script>
</body>
</html>