Files
ko-grammar/docs/.vitepress/theme/components/AudioButton.vue
T
2026-03-25 05:08:27 +07:00

25 lines
462 B
Vue
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<span>
<button type="button" @click="playAudio()">▶️</button>
<audio ref="audio" style="display: none"></audio>
</span>
</template>
<script setup lang="ts">
import { useTemplateRef } from "vue";
const props = defineProps<{
src: string;
}>();
const audioEl = useTemplateRef("audio");
function playAudio() {
if (!audioEl.value) return;
audioEl.value.src = props.src;
audioEl.value.play();
}
</script>
<style module></style>