From 7a373b6aea9db1c387f9f3d552e908e51ab7d9d5 Mon Sep 17 00:00:00 2001 From: Rashid Pathiyil Date: Fri, 29 Jul 2022 13:38:22 +0530 Subject: [PATCH] docs(app-vite&app-webpack): Accessing router in Pinia&Vuex (#14079) Co-authored-by: Yusuf Kandemir Co-authored-by: Scott --- .../state-management-with-pinia.md | 18 ++++++++++++++++++ .../state-management-with-vuex.md | 11 +++++++++++ .../state-management-with-pinia.md | 18 ++++++++++++++++++ .../state-management-with-vuex.md | 11 +++++++++++ 4 files changed, 58 insertions(+) diff --git a/docs/src/pages/quasar-cli-vite/state-management-with-pinia.md b/docs/src/pages/quasar-cli-vite/state-management-with-pinia.md index e9c124b819f..97c02935620 100644 --- a/docs/src/pages/quasar-cli-vite/state-management-with-pinia.md +++ b/docs/src/pages/quasar-cli-vite/state-management-with-pinia.md @@ -148,3 +148,21 @@ export default { ``` [More info on defining a Pinia store](https://pinia.vuejs.org/core-concepts/). + +## Accessing the router in Pinia stores + +Simply use `this.router` in Pinia stores to get access to the router. + +Here is an example: +```js +import { defineStore } from 'pinia' + +export const useWhateverStore = defineStore('whatever', { + // ... + actions: { + whateverAction () { + this.router.push('...') + } + } +} +``` \ No newline at end of file diff --git a/docs/src/pages/quasar-cli-vite/state-management-with-vuex.md b/docs/src/pages/quasar-cli-vite/state-management-with-vuex.md index 14d3e384304..3f6b2673259 100644 --- a/docs/src/pages/quasar-cli-vite/state-management-with-vuex.md +++ b/docs/src/pages/quasar-cli-vite/state-management-with-vuex.md @@ -455,3 +455,14 @@ export default defineComponent({ }); ``` + +## Accessing the router in Vuex stores + +Simply use `this.$router` in Vuex stores to get access to the router. + +Here is an example: +```js +export function whateverAction (state) { + this.$router.push('...') +} +``` \ No newline at end of file diff --git a/docs/src/pages/quasar-cli-webpack/state-management-with-pinia.md b/docs/src/pages/quasar-cli-webpack/state-management-with-pinia.md index c19e142bb11..9af89407803 100644 --- a/docs/src/pages/quasar-cli-webpack/state-management-with-pinia.md +++ b/docs/src/pages/quasar-cli-webpack/state-management-with-pinia.md @@ -148,3 +148,21 @@ export default { ``` More info on defining a Pinia store [here](https://pinia.vuejs.org/core-concepts/). + +## Accessing the router in Pinia stores + +Simply use `this.router` in Pinia stores to get access to the router. + +Here is an example: +```js +import { defineStore } from 'pinia' + +export const useWhateverStore = defineStore('whatever', { + // ... + actions: { + whateverAction () { + this.router.push('...') + } + } +} +``` \ No newline at end of file diff --git a/docs/src/pages/quasar-cli-webpack/state-management-with-vuex.md b/docs/src/pages/quasar-cli-webpack/state-management-with-vuex.md index 8df46db4568..ec89f9f1139 100644 --- a/docs/src/pages/quasar-cli-webpack/state-management-with-vuex.md +++ b/docs/src/pages/quasar-cli-webpack/state-management-with-vuex.md @@ -455,3 +455,14 @@ export default defineComponent({ }); ``` + +## Accessing the router in Vuex stores + +Simply use `this.$router` in Vuex stores to get access to the router. + +Here is an example: +```js +export function whateverAction (state) { + this.$router.push('...') +} +``` \ No newline at end of file