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.