url传参问题:
1)params传参:/about/110
规则:
{path:"/about/:id",name:"about",component:About},
在组件中获取:
this.$route.params.id
2)query传参:/about?id=110
规则:
{path:"/home",name:"home", component:Home},
在组件中获取:
this.$route.query.id
例子:
<script>
export default {
name: "About",
created() {
console.log(this.$route.params.id)
}
}
</script>