https://github.com/imcvampire/vue-reload-route-data
A small Vuejs mixin for reload route data manually
https://github.com/imcvampire/vue-reload-route-data
Last synced: 8 months ago
JSON representation
A small Vuejs mixin for reload route data manually
- Host: GitHub
- URL: https://github.com/imcvampire/vue-reload-route-data
- Owner: imcvampire
- License: other
- Created: 2016-12-05T08:16:02.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-28T03:15:06.000Z (almost 9 years ago)
- Last Synced: 2024-04-26T03:20:44.449Z (over 1 year ago)
- Language: JavaScript
- Size: 25.4 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-vue-refactor - vue-reload-route-data
README
# vue-reload-route-data
A small Vuejs mixin for reload route data manually. Mainly inspired by https://gist.github.com/fnlctrl/1cf9da63493e0fe78181a4f4e2cc6f64
## How to install:
### CommonJS:
```
npm install --save vue-reload-route-data
```
And in your entry file:
```
import Vue from 'vue'
import VueReloadRouteData from 'vue-reload-route-data'
Vue.use(VueReloadRouteData, {
immediate: true
})
`immediate` will be passed to 3rd param of `$watch` for `$route`
```
### Script:
Just add 3 scripts in order: `vue`, `vue-reload-route-data` to your `document`.
## How to use:
Send all your code to load route data to `fetchRouteData`.
```js
export default {
data() {
return {
data: {}
]
},
fetchRouteData() {
// Get your route data
this.$set(this, 'data', someRouteData)
}
}
```
After that, you can call `reloadRouteData` anytime you want to reload data.