继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

vue params 链接传值

慕雪0461719
关注TA
已关注
手记 1
粉丝 4
获赞 1

HelloWord.vue

<template>
  <div class="hello">
    <h1>{{msg}}</h1>
    <router-link :to="{ name:'children', params: {id: 222,cid:333} }">
      显示
    </router-link>
  </div>
</template>

children.vue

<template>
    <div>{{ id }}--{{ cid }}</div>
</template>
<script>
export default {
    name:'children',
    data(){
        return{
            id:'',
            cid:''
        }
    },
    created(){
        this.id = this.$route.params.id,
        this.cid = this.$route.params.cid
    }
}
</script>
<style scoped>

</style>

router.vue

import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import children from '@/components/children'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld
    },
    {
      path:'/detail/:id',
      name:'children',
      component:children
    }
  ]
})

记录一下!

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP