vue3-core/playground/src/App.vue

50 lines
1.0 KiB
Vue
Raw Normal View History

2023-11-17 03:01:19 +08:00
<script setup lang="ts">
2023-11-23 23:42:08 +08:00
import { ref, computed } from 'vue'
2023-11-17 03:01:19 +08:00
2023-11-24 15:25:34 +08:00
const count = ref(1)
2023-11-23 23:42:08 +08:00
const double = computed(() => count.value * 2)
2023-11-24 14:44:57 +08:00
const html = computed(() => `<button>HTML! ${count.value}</button>`)
2023-11-23 23:42:08 +08:00
const inc = () => count.value++
const dec = () => count.value--
// @ts-expect-error
globalThis.count = count
// @ts-expect-error
globalThis.double = double
// @ts-expect-error
globalThis.inc = inc
// @ts-expect-error
globalThis.dec = dec
2023-11-24 14:44:57 +08:00
// @ts-expect-error
globalThis.html = html
2023-11-17 03:01:19 +08:00
</script>
<template>
<div>
2023-11-23 23:42:08 +08:00
<h1 class="red">Counter</h1>
<div>The number is {{ count }}.</div>
<div>{{ count }} * 2 = {{ double }}</div>
<div style="display: flex; gap: 8px">
<button @click="inc">inc</button>
<button @click="dec">dec</button>
</div>
2023-11-24 14:59:10 +08:00
<div v-html="html" />
<div v-text="html" />
2023-11-24 15:25:34 +08:00
<div v-once>once: {{ count }}</div>
2023-11-24 15:37:49 +08:00
<div v-pre>{{ count }}</div>
2023-11-17 03:01:19 +08:00
</div>
</template>
<style>
.red {
color: red;
}
2023-11-23 23:42:08 +08:00
html {
color-scheme: dark;
background-color: #000;
padding: 10px;
}
2023-11-17 03:01:19 +08:00
</style>