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

HTML page native VIDEO tag hides the download button function

When writing a web project, I encountered an intr...

How to use docker to deploy front-end applications

Docker is becoming more and more popular. It can ...

Easyswoole one-click installation script and pagoda installation error

Frequently asked questions When you are new to ea...

Detailed explanation of HTML programming tags and document structure

The purpose of using HTML to mark up content is t...

Summary of Several Methods for Implementing Vertical Centering with CSS

In the front-end layout process, it is relatively...

Solution to Apache cross-domain resource access error

In many cases, large and medium-sized websites wi...

How to select all child elements and add styles to them in CSS

method: Take less in the actual project as an exa...

Use three.js to achieve cool acid style 3D page effects

This article mainly introduces how to use the Rea...

How to use cookies to remember passwords for 7 days on the vue login page

Problem Description In the login page of the proj...

Introduction to Apache deployment of https in cryptography

Table of contents Purpose Experimental environmen...

JavaScript canvas to achieve meteor effects

This article shares the specific code for JavaScr...

Vue3 list interface data display details

Table of contents 1. List interface display examp...