examples: add initial class to basic
This commit is contained in:
+14
-5
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user