From 594c45f519dc0fc71ec92fa275074dbb5f2f3609 Mon Sep 17 00:00:00 2001 From: Valentin Kaelin Date: Fri, 14 Feb 2020 19:34:11 +0100 Subject: [PATCH] refactor: watch vue router changes with $route --- client/src/layouts/Default.vue | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/client/src/layouts/Default.vue b/client/src/layouts/Default.vue index b5aab12..d7861e6 100644 --- a/client/src/layouts/Default.vue +++ b/client/src/layouts/Default.vue @@ -107,8 +107,8 @@ - + @@ -150,15 +150,6 @@ export default { }, computed: { - summoner() { - return this.$route.params.name - }, - region() { - return this.$route.params.region - }, - uri() { - return `${this.summoner}|${this.region}` - }, tabTransition() { return this.summonerFound && this.overviewLoaded ? 'tab' : 'none' }, @@ -169,21 +160,19 @@ export default { }, watch: { - uri() { - console.log('route changed') - this.updateSettings({ name: 'region', value: this.region.toLowerCase() }) + $route() { this.apiCall() } }, created() { - this.updateSettings({ name: 'region', value: this.region.toLowerCase() }) this.apiCall() }, methods: { apiCall() { - this.basicRequest({ summoner: this.summoner, region: this.region }) + this.updateSettings({ name: 'region', value: this.$route.params.region.toLowerCase() }) + this.basicRequest({ summoner: this.$route.params.name, region: this.$route.params.region }) }, isRouteActive(currentRoute) { return {