1, add routes
Enter vue add router in cmd
To use the historical model? Select No
After installing the src folder will be more than two files: views and router.js
There are two views components
router.js routing configuration
Which just introduced router is installed, vue-router will put node_modules, the direct use can be introduced
Home is introduced from the views of
Vue.use (Router) is to use vue router, routing will not take effect if you do not write, and it will add two things to vue examples use these words: $ router (routing methods) $ route (on routing attributes )
What routing configuration must first consider what the path is to show content
Equipped with two paths
After the second component is a routing function, the purpose is to lazy loading, increase the speed of loading the first screen, you can just start to load up the page corresponding to the root path of the home, only to switch to the back of the page when it loads the page
component: () => import(/* webpackChunkName: "about" */ './views/About.vue')
import is introduced, introducing the assembly out of a value component
Configured path, the path is to be exported: export default
Into main.js
The introduction of the router in main.js
And using the new Vue a router (it uses short, in fact form router: router)
Instructions:
Routing modes:
In two ways: 1, the historical pattern of history 2, hash (#)
hash without having to refresh the page
General use history mode, you can make use of history does not appear #