Vue2 navigation modifies the instance of the navigation content based on the route value, vue2 instance

Source: Internet
Author: User
Tags sessionstorage

Vue2 navigation modifies the instance of the navigation content based on the route value, vue2 instance

In projects, our navigation is generally the same as long, but the content will change according to the content of the previous page. We only need to use the top navigation as an independent public component, so that we can easily introduce components wherever necessary.

The public navigation code is as follows: (mineHeader. vue)

<Template> <section class = "listHeader"> <section class = "header" @ click = "back ()">  <p >{{ mineHeaderData }}</p> </section> </template> <script> export default {name: 'minhead', props: {mineHeaderData: String}, data () {return {msg: "Profile Header" }}, methods: {back: function () {this. $ router. go ('-1') ;}}</script>

For example, on a page, there are three modules that need to jump to a public component based on different modules, but the header content must match the module content. As follows:

<Template> <section class = "tiket"> <section class = "top" v-for = "(item, index) in sortList" @ click = "toNext (index) "> <section> 

The final interface is as follows:

Then we need to click on each module to jump to the next page, and the navigation content also becomes the corresponding content. The tiketOrder. vue page must be written as follows,

<Template> <section class = "tiket"> <MineHeader: mineHeaderData = 'ticketname'> </MineHeader> <section class = "top" v-for = "(item, index) in sotList "> <section> 

Last example:

This completes. In fact, many components in a project can be reused, so that we can write fewer components.

In the preceding vue2 navigation article, the example of changing the navigation content is all the content that I shared with you through the route. I hope to give you a reference and support for the customer's house.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.