vue router用法

//routes.js
import AA from './components/AA.vue'
import BB from './components/BB.vue'
import CC from './components/CC.vue'
export default[
{path:"/",component:AA},
{path:"/BB",component:BB},
{path:"/CC/:id",component:CC},//冒号+参数名
]
//AA.VUE
<router-link to="/" exact>AA</router-link>
<router-link to="/BB" exact>BB</router-link>//导航有默认样式加exact
<router-link v-bind:to="'/cc/'+id"> //传数据加上 v-bind
//接收页CC.vue
data() {
return {
id: this.$route.params.id,
};
},

猜你喜欢

转载自www.cnblogs.com/lovelingtaste/p/10648092.html
今日推荐