1
0
mirror of https://github.com/robonen/canvas-3d.git synced 2026-03-20 02:44:40 +00:00

feat(components): HtmlElementEvent type and canvas testing

This commit is contained in:
2022-11-20 04:52:31 +07:00
parent c4ea966e94
commit eec4d3d061
8 changed files with 606 additions and 576 deletions

View File

@@ -12,7 +12,7 @@ const showForm = ref<boolean>(false);
<IconOpen v-else/>
</button>
</div>
<div class="content" v-if="showForm">
<div class="content" v-show="showForm">
<slot/>
</div>
</section>

18
src/components/board.vue Normal file
View File

@@ -0,0 +1,18 @@
<script setup lang="ts">
const canvas = ref<HTMLCanvasElement | null>(null);
onMounted(() => {
if (!canvas.value) return;
const ctx = canvas.value.getContext("2d");
if (!ctx) return;
ctx.fillStyle = "red";
ctx.fillRect(0, 0, Math.random() * 100, Math.random() * 100);
});
</script>
<template>
<canvas ref="canvas" />
</template>

View File

@@ -1,4 +1,6 @@
<script setup lang="ts">
import {HTMLElementEvent} from '@/types/dom';
const {
label,
min,
@@ -14,10 +16,10 @@ const emit = defineEmits<{
const value = ref<number>(defaultValue);
const onChange = (event: Event) => {
value.value = (event.target as HTMLInputElement).valueAsNumber;
const {target} = event as HTMLElementEvent<HTMLInputElement>;
value.value = target.valueAsNumber;
emit('change', value.value);
};
</script>
<template>