How to implement page jump in Vue project

How to implement page jump in Vue project

Problem description:

vue-router is a module used to implement routing page jumps in front-end development. Below, the editor will show you how to implement page jump based on the already created vue-router project.

Experimental results and discussion:

1. Create a vue-cli default project (containing only babel)

2. Enter the creation file

Enter the created file path as an administrator and run the command npm install vue-router –save

(If the Taobao image has been installed, run cnpm install vue-router-save)

3. Check the configuration

In package.json, you can check whether vue-router has been successfully configured.

4. Create views folder

Create a new views folder and create two components, home.vue and about.vue, in this folder

5. Set up APP.vue

Set up as follows:

<template>

<div id="app">

<div id="nav">

<router-link to="/">home</router-link> |

<router-link to="/about">about</router-link>

</div>

<router-view/>

</div>

</template>

<style>

#app {

text-align: center;

margin-top: 60px;

}

</style>

6. Configure main.js

import Vue from 'vue'

import Router from 'vue-router'

import Home from './views/Home.vue'

Vue.use(Router)

export default new Router({

mode: 'history',

base: process.env.BASE_URL,

routes: [

{

path: '/',

name: 'home',

component: Home

},

{

path: '/about',

name: 'about',

component: () => import( './views/About.vue')

}

]

})

7. Operation results

as follows:

Summary of the problem:

In this experiment, vue-router is installed in the cmd command prompt, and router.js is configured to implement the page jump function. Although a simple page jump function has been successfully implemented, the definition of routes and components in router.js has not been explained clearly. The page jump function will be studied later.

This is the end of this article about how to implement page jump in vue project. For more relevant content about how to implement page jump in vue project, please search previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • VUE develops the background management page steps of the distributed medical registration system
  • Example steps for VUE to build a distributed medical registration system backend management page
  • Vue realizes screen adaptation of large screen pages
  • VUE develops hospital settings page steps for distributed medical registration system

<<:  HTML4.0 element default style arrangement

>>:  CSS3 implements horizontal centering, vertical centering, horizontal and vertical centering example code

Recommend

JavaScript implementation of drop-down list

This article example shares the specific code of ...

Basic knowledge of MySQL learning notes

View Database show databases; Create a database c...

The perfect solution for forgetting the password in mysql8.0.19

Recommended reading: MySQL 8.0.19 supports accoun...

Nginx handles http request implementation process analysis

Nginx first decides which server{} block in the c...

A brief discussion on the synchronization solution between MySQL and redis cache

Table of contents 1. Solution 1 (UDF) Demo Case 2...

Vue implements button switching picture

This article example shares the specific code of ...

JS interview question: Can forEach jump out of the loop?

When I was asked this question, I was ignorant an...

Mini Program natively implements left-slide drawer menu

Table of contents WXS Response Event Plan A Page ...

MySQL database aggregate query and union query operations

Table of contents 1. Insert the queried results 2...

How to use the realip module in Nginx basic learning

Preface There are two types of nginx modules, off...

How to use Vue3 mixin

Table of contents 1. How to use mixin? 2. Notes o...

Solution for VMware Workstation Pro not running on Windows

After the National Day holiday, did any of you fi...

Analysis of uniapp entry-level nvue climbing pit record

Table of contents Preface Hello World image Set b...

base target="" specifies the target of the base link to open the frame

<base target=_blank> changes the target fram...

Simple example of using Docker container

Table of contents 1. Pull the image 2. Run the im...