Last active
April 14, 2020 11:50
-
-
Save manakuro/b40cc81aed1fb27ee385783b9acde339 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
<script lang="ts"> | |
import { | |
computed, | |
defineComponent, | |
reactive, | |
watch | |
} from '@vue/composition-api' | |
import Logo from '~/components/Logo.vue' | |
export default defineComponent({ | |
components: { | |
Logo | |
}, | |
setup(_, ctx) { | |
const route = ctx.root.$route | |
const state = reactive({ route }) | |
watch( | |
() => ctx.root.$route, | |
(r) => { | |
state.route = r as any | |
} | |
) | |
const myQuery = computed(() => state.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