Last active
April 14, 2020 12:18
-
-
Save manakuro/f02b955921f8a3442460209e1f686f53 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="container"> | |
<div> | |
<logo /> | |
<h2 class="subtitle">Reactive Router query: {{ myQuery }}</h2> | |
<div class="links"> | |
<a | |
class="button--grey" | |
@click="handleClick" | |
> | |
Change Router Query | |
</a> | |
</div> | |
</div> | |
</div> | |
</template> | |
<script lang="ts"> | |
import { computed, defineComponent } from '@vue/composition-api' | |
import Logo from '~/components/Logo.vue' | |
export default defineComponent({ | |
components: { | |
Logo | |
}, | |
setup(_, ctx) { | |
const route = ctx.root.$route | |
const myQuery = computed(() => route.query.myQuery) | |
const handleClick = (e: Event) => { | |
e.preventDefault() | |
ctx.root.$router.push({ query: { myQuery: 'handle my query!' } }) | |
} | |
return { | |
myQuery, | |
handleClick | |
} | |
} | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment