current position:Home>Use Vue router in Vue project

Use Vue router in Vue project

2022-04-29 16:10:35X Beichen North


Here is only a simple record , Didn't make a detailed arrangement .


Operation steps

1、 Install the routing through the following command , as follows :

npm install vue-router --save-dev

2、 stay src New at root router Folder , Then build router.js file , Enter the following code :

import Vue from 'vue';
import Router from 'vue-router';

import DataSource from '../components/system/content/dataSource/DataSource.vue';


export default new Router({
    routes: [
            path: '/',
            component: DataSource
    mode: 'history'

3、 And then in main.js Introduce this in router.js file , as follows :


4、 Insert... In the appropriate container <router-view></router-view> and <router-link to='/test'></router-link> Label to configure routing .


Another way


The configured <router-view> Then match this.$router.push() Method to realize click jump , Please refer to the official website for details .


copyright notice
author[X Beichen North],Please bring the original link to reprint, thank you.

Random recommended