安装
npm install vuex-router-sync --save
配置使用
import {sync} from 'vuex-router-sync'
sync(store, router)
通过sync方法把store跟router连接起来,在vue组件中this.$store.state.route
,返回结果即router中的currentRoute
对象
源码
1 | exports.sync = function (store, router, options) { |