--- /dev/null
+<template>
+ <a href="#" role="button" @click.prevent="open" ref="el">
+ <img :src="img" :alt="title" style="border-radius: 6px" />
+ </a>
+</template>
+
+<script setup lang="ts">
+import { ref } from 'vue'
+
+const props = defineProps({
+ title: {
+ type: String,
+ required: true,
+ default: 'Get started with Vue Router',
+ },
+ img: {
+ type: String,
+ required: true,
+ },
+ url: {
+ type: String,
+ required: true,
+ },
+})
+
+const isOpened = ref(false)
+const el = ref<HTMLElement>()
+
+function open() {
+ // dropped v-if/v-else way to fix autoplay issue on Chrome
+ // https://github.com/vuejs/vuex/pull/1453#issuecomment-441507095
+ isOpened.value = true
+ const element = el.value
+ if (!element || !element.parentNode) {
+ return
+ }
+ const attrs = {
+ width: '640',
+ height: '360',
+ frameborder: '0',
+ src: props.url + '?autoplay=1',
+ webkitallowfullscreen: 'true',
+ mozallowfullscreen: 'true',
+ allowfullscreen: 'true',
+ }
+ const video = document.createElement('iframe')
+ for (const name in attrs) {
+ video.setAttribute(name, attrs[name as keyof typeof attrs])
+ }
+ element.parentNode.replaceChild(video, element)
+}
+</script>
# Getting Started
+<VueMasteryVideo
+ title="Get Started with Vue Router"
+ url="https://player.vimeo.com/video/548250062"
+ img="https://i.vimeocdn.com/video/1201118933_640"
+/>
+
+<script setup>
+ import VueMasteryVideo from '../.vitepress/components/VueMasteryVideo.vue'
+ </script>
+
Creating a Single-page Application with Vue + Vue Router feels natural: with Vue.js, we are already composing our application with components. When adding Vue Router to the mix, all we need to do is map our components to the routes and let Vue Router know where to render them. Here's a basic example:
## HTML