examples: add initial class to basic

This commit is contained in:
Braks
2022-04-24 13:34:22 +02:00
parent 19bc4fda24
commit bb30db7c08
3 changed files with 23 additions and 13 deletions
+14 -5
View File
@@ -4,17 +4,26 @@ import { routes } from './router'
const router = useRouter()
const route = useRoute()
const onChange = (event: any) => {
router.push(event.target.value)
const onChange = (event: Event) => {
router.push((event.target as HTMLSelectElement).value)
}
const computedRoutes = computed(() => {
return routes
.filter((r) => r.path !== '/')
.map((r) => ({
path: r.path,
label: r.path.substring(1),
}))
})
</script>
<template>
<header>
<a class="logo" href="https://github.com/bcakmakoglu/vue-flow"> Vue Flow Dev </a>
<select v-model="route.path" @change="onChange">
<template v-for="r of routes" :key="r.path">
<option v-if="r.path !== '/'" :value="r.path">
{{ r.path.substr(1, r.path.length) }}
<template v-for="r of computedRoutes" :key="r.path">
<option :value="r.path">
{{ r.label }}
</option>
</template>
</select>