vue params 链接传值
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
}
]
})
记录一下!
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦