Home > Web Front-end > Vue.js > How to configure routing in vue.js

How to configure routing in vue.js

王林
Release: 2023-01-13 00:45:47
Original
2945 people have browsed it

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...】.

How to configure routing in vue.js

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
Copy after login

Reference

import VueRouter from 'vue-router'
Copy after login

Configuration routing file

var router = new VueRouter({
   routes:[
    {
      path:"/hello",
      component:HelloWorld
    },
    {
      path:"/wen",
      component:HelloWen
    }
   ]
   })
    
   new Vue({
   el: '#app',
   components: { App },
   router,
   template: &#39;<App/>&#39;
   })
Copy after login

View loaded Location

Add

to the default App.vue file

Jump navigation

Recommended learning:
php Training######

The above is the detailed content of How to configure routing in vue.js. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template