How to configure routing in vue.js: 1. Install vue-router; 2. Reference vue-router; 3. Configure routing files, such as [var router = new VueRouter({routes:[{path:" /hello",component...】.
The operating environment of this article: windows10 system, vue.js 2.9, thinkpad t480 computer.
The steps for vue.js to configure routing are as follows:
Installation
npm install --save vue-router
Reference
import VueRouter from 'vue-router'
Configuration routing file
var router = new VueRouter({ routes:[ { path:"/hello", component:HelloWorld }, { path:"/wen", component:HelloWen } ] }) new Vue({ el: '#app', components: { App }, router, template: '<App/>' })
View loaded Location
Add
to the default App.vue file