Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ljhhhhhh committed Oct 9, 2019
1 parent c9878c3 commit 2885ced
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<div id="app">
<div id="nav">
<router-link to="/?id=3">Home</router-link> |
<router-link to="/about?id=1">About</router-link>
<router-link to="/">Home</router-link> |
<router-link to="/">About</router-link>
</div>
<router-view/>
</div>
Expand Down
7 changes: 7 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Vue from 'vue'
import Router from 'vue-router'
import Home from '../views/Home.vue'
import store from '@/store'

Vue.use(Router)

Expand Down Expand Up @@ -30,7 +31,13 @@ const myRouter = new Router({
routes
})

const history = window.sessionStorage
history.clear()
let historyCount = history.getItem('count') * 1 || 0
history.setItem('/', 0)

myRouter.beforeEach((to, from, next) => {
console.log(to.params, 'to.params')
if (to.params.direction) {
store.commit('updateDirection', to.params.direction)
} else {
Expand Down
6 changes: 5 additions & 1 deletion src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Vue.use(Vuex)
export default new Vuex.Store({
state: {
msg: 'hello vuex',
loading: false
loading: false,
direction: 'forward'
},
getters: {
loading (state) {
Expand All @@ -20,6 +21,9 @@ export default new Vuex.Store({
},
setLoading (state, val) {
state.loading = val
},
updateDirection (state, direction) {
state.direction = direction
}
},
actions: {
Expand Down

0 comments on commit 2885ced

Please sign in to comment.