Skip to content

Commit 9d3409e

Browse files
committed
fix: add a VueUse demo
1 parent f11d477 commit 9d3409e

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

playground/scenarios/vueUse/App.vue

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<template>
2+
<div class="app-container">
3+
<Coordinate label="X" :value="x" />
4+
<Coordinate label="Y" :value="y" />
5+
</div>
6+
</template>
7+
8+
<script lang="ts" setup>
9+
import { useMouse } from '@vueuse/core'
10+
import Coordinate from './Coordinate.vue'
11+
12+
const { x, y } = useMouse()
13+
</script>
14+
15+
<style scoped>
16+
.app-container {
17+
display: grid;
18+
grid-auto-flow: column;
19+
gap: 1rem;
20+
justify-content: center;
21+
align-items: center;
22+
height: 100vh;
23+
font-family: monospace;
24+
}
25+
</style>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<template>
2+
<div class="coordinate">
3+
<span class="coordinate-value">{{ value }}</span>
4+
<span class="coordinate-label"> Mouse {{ label }} </span>
5+
</div>
6+
</template>
7+
8+
<script lang="ts" setup>
9+
defineProps<{
10+
label: string
11+
value: number
12+
}>()
13+
</script>
14+
15+
<style scoped>
16+
.coordinate {
17+
font-family: monospace;
18+
background-color: #f3f4f6; /* light-500 */
19+
color: #111827; /* dark-900 */
20+
display: flex;
21+
flex-direction: column;
22+
text-align: center;
23+
padding: 0.5rem;
24+
border-radius: 0.5rem;
25+
}
26+
.coordinate-value {
27+
font-size: 2.25rem; /* text-4xl */
28+
}
29+
.coordinate-label {
30+
font-size: 0.875rem; /* text-sm */
31+
margin-top: 0.5rem;
32+
color: #2563eb; /* blue-600, 更明显 */
33+
opacity: 0.8;
34+
}
35+
</style>

playground/scenarios/vueUse/_meta.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
mainFile: 'App.vue',
3+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"imports": {
3+
"vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js",
4+
"@vueuse/core": "https://unpkg.com/@vueuse/[email protected]/index.mjs",
5+
"@vueuse/shared": "https://unpkg.com/@vueuse/[email protected]/index.mjs",
6+
"vue-demi": "https://cdn.jsdelivr.net/npm/[email protected]/lib/v3/index.mjs"
7+
}
8+
}

0 commit comments

Comments
 (0)