App.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <script setup lang="ts">
  2. import { ref, computed } from 'vue/vapor'
  3. const count = ref(1)
  4. const double = computed(() => count.value * 2)
  5. const html = computed(() => `<button>HTML! ${count.value}</button>`)
  6. const inc = () => count.value++
  7. const dec = () => count.value--
  8. // @ts-expect-error
  9. globalThis.count = count
  10. // @ts-expect-error
  11. globalThis.double = double
  12. // @ts-expect-error
  13. globalThis.inc = inc
  14. // @ts-expect-error
  15. globalThis.dec = dec
  16. // @ts-expect-error
  17. globalThis.html = html
  18. </script>
  19. <template>
  20. <div>
  21. <h1 class="red">Counter</h1>
  22. <div>The number is {{ count }}.</div>
  23. <div>{{ count }} * 2 = {{ double }}</div>
  24. <div style="display: flex; gap: 8px">
  25. <button @click="inc">inc</button>
  26. <button @click="dec">dec</button>
  27. </div>
  28. <div v-html="html" />
  29. <div v-text="html" />
  30. <div v-once>once: {{ count }}</div>
  31. <div v-pre>{{ count }}</div>
  32. <div v-cloak>{{ count }}</div>
  33. </div>
  34. </template>
  35. <style>
  36. .red {
  37. color: red;
  38. }
  39. html {
  40. color-scheme: dark;
  41. background-color: #000;
  42. padding: 10px;
  43. }
  44. </style>