Skip to content

Commit 49a8fb4

Browse files
committed
Add a new counter feature with Vue component setup
Introduce a basic counter application using Vue, including a new HTML entry point (`counter.html`), a JavaScript module (`counter.js`), and a Vue component (`Counter.vue`). Also update `vite.config.js` to include the new entry point.
1 parent 155beb9 commit 49a8fb4

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

counter.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + Vue</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
<script type="module" src="/src/counter.js"></script>
12+
</body>
13+
</html>

src/components/Counter.vue

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<script setup>
2+
import {nextTick, ref} from "vue";
3+
4+
console.info(`Load component`);
5+
let counter = ref({
6+
count: 0,
7+
name: "Eko"
8+
});
9+
10+
async function increment(){
11+
console.info(`Increment counter : ${counter.value.count}`);
12+
counter.value = {
13+
name: counter.value.name,
14+
count: counter.value.count + 1
15+
};
16+
17+
await nextTick();
18+
19+
counter.value.count++;
20+
21+
await nextTick();
22+
23+
counter.value.count++;
24+
25+
await nextTick();
26+
27+
console.log("Increment count after nextTick");
28+
}
29+
</script>
30+
31+
<template>
32+
<div>
33+
<h1 id="count">Counter {{counter.name}} : {{counter.count}}</h1>
34+
<button v-on:click="increment">Increment</button>
35+
</div>
36+
</template>
37+
38+
<style scoped>
39+
40+
</style>

src/counter.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import {createApp} from "vue";
2+
import Counter from "./components/Counter.vue";
3+
4+
createApp(Counter).mount("#app");

vite.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default defineConfig({
99
input: {
1010
index: "index.html",
1111
hello: "hello.html",
12+
counter: "counter.html",
1213
}
1314
}
1415
}

0 commit comments

Comments
 (0)