Skip to content

Commit

Permalink
docs(app-vite&app-webpack): Accessing router in Pinia&Vuex (#14079)
Browse files Browse the repository at this point in the history
Co-authored-by: Yusuf Kandemir <yusuf.kandemir@outlook.com.tr>
Co-authored-by: Scott <smolinari@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 29, 2022
1 parent ca2b26f commit 7a373b6
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/src/pages/quasar-cli-vite/state-management-with-pinia.md
Original file line number Diff line number Diff line change
Expand Up @@ -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('...')
}
}
}
```
11 changes: 11 additions & 0 deletions docs/src/pages/quasar-cli-vite/state-management-with-vuex.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,14 @@ export default defineComponent({
});
</script>
```

## 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('...')
}
```
18 changes: 18 additions & 0 deletions docs/src/pages/quasar-cli-webpack/state-management-with-pinia.md
Original file line number Diff line number Diff line change
Expand Up @@ -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('...')
}
}
}
```
11 changes: 11 additions & 0 deletions docs/src/pages/quasar-cli-webpack/state-management-with-vuex.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,14 @@ export default defineComponent({
});
</script>
```

## 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('...')
}
```

0 comments on commit 7a373b6

Please # to comment.