为了账号安全,请及时绑定邮箱和手机立即绑定

vue params 链接传值

2019.11.26 22:58 2846浏览

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
    }
  ]
})

记录一下!

点击查看更多内容
0人点赞

若觉得本文不错,就分享一下吧!

评论

相关文章推荐

正在加载中
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消