VueRouter之props参数
只要在配置路由的时候增加props:true
children: [
{
path: 'detail/:id/:content',
name: 'detail',
props:true,
component: () => import('../views/DetailView.vue'),
}
]
不么在DetailView.vue这个页面中,就可以直接使用传递过来的params参数了
<template>
<ul class="">
<li>
编号:{{ id }}
<hr />
</li>
<li>
内容:{{ content }}
</li>
</ul>
</template>
<script>
export default {
mixins: [],
components: {},
props: ['id', 'content'],
data() {
return {
}
},
computed: {},
watch: {},
created() { },
mounted() {
console.log(this.$route);
},
methods: {},
}
</script>
<style scoped></style>