vue-router 参数传递

 

 <router-link to="/home"  replace>首页</router-link>
    <router-link to="/about"  replace>关于</router-link>

    <!-- <router-link :to="/user/+userId"  replace>用户</router-link>  -->
    <!-- <router-link to="/profile">档案</router-link> --> 
    <!-- <router-link :to="{path:'/profile',query:{name:'Eric',age:'25'}}">档案</router-link> -->
 
    <button @click="userClick">用户</button>
    <button @click="profileClick">档案</button>

 

  userClick(){
      this.$router.push('/user/' + this.userId )
    },
    profileClick(){
      this.$router.push({
        path:'/profile',
        query:{
          name: 'Eric',
          age: 18
        }
      })
    }
相关文章
相关标签/搜索