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
|
|
|
|
|
|
|
const count = ref(0)
|
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:48:51 +08:00
|
|
|
<div v-html="html"></div>
|
|
|
|
<div v-text="html"></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>
|