Where is the router.beforeEach written when the project built by vue-cli sets the title for each page?

clipboard.png

clipboard.png

reported that there is no definition for router. May I ask why?

Mar.19,2021

write under main.js


look at your code and put it all in the js file of routing configuration. Your router is not defined. Of course, you report undefined when you use it. The correct posture is to put router.beforeEach in main.js. Of course, first of all, you need to import router from 'xxx/index.js', in main.js, that is, introduce your routing profile


suggest putting it in main.js, and then your route is also injected into-sharpapp


.

first of all, look at the case clearly. router is not defined.

you should be copied code from somewhere else.
that file is import router from 'router.js'

in main.js .

so this router is actually your export default going out new Router ()

.

clipboard.png

Menu