Vue page jumps and passes parameters

First register a page Underrank.vue and configure the path in main.js

{ path: '/underrank', name: 'underrank', component: () => import('@/views/inner/UnderRank') },

Add where page jump is required

<router-link
        :to="{
          name: 'underrank',
          params: {
            rankid: item.rankid,
          },
        }"
      >
      </router-link>

It can also be added via this.$router.push.

 In Underrank.vue, the parameter value is obtained through this.$route.params.rankid in the mounted function.

 data() {
    return {
      rankid: 0
    }
  },
  mounted() {
    this.rankid = this.$route.params.rankid
    console.log(`rankid :${this.rankid }`)
  },

Guess you like

Origin blog.csdn.net/DW_css/article/details/122683877