Vue.js3です。

<script type="ts" setup>
import { ref, onMounted } from 'vue'

const test = ref<HTMLCanvasElement|null>(null)

onMounted(async () => {
    if (!test) return

    const ctx = test.getContext('2d')
})
</script>

<template>
    <canvas ref="test"></canvas>
</template>