How to introduce vue-router into vuex file to get routing information?

if you want to use the meta field data in router in other js files or vuex, how to introduce it?
import router from". / router"
cannot be used after this introduction

Jul.04,2021

solved, it's on the prototype chain of vue, but it's not very elegant.

< hr >

it still doesn't work. Console.log (router.app) comes out as undefined, but there is

in console.log (router).

introduces main.js. It is then referenced from the vue instance exposed in main.js. Either route or vuex is fine.


have you solved it? I have the same problem. When introduced, undefind


this is how I get the current routing path in vuex. I hope it will be helpful to you.

import router from '@/router'
console.log('=>',router.app._route.name);
Menu