This commit is contained in:
2021-07-07 17:08:47 +08:00
parent d3d64cd25e
commit 29736567e8
3 changed files with 17 additions and 5 deletions

View File

@@ -32,7 +32,7 @@ const routes = [
{ {
path: '/index', component: index, children: [ path: '/index', component: index, children: [
{ {
path: 'foo', component: foo, children: [{ path: 'foo/:name/:age', name:"foo", component: foo, children: [{
path: 'aaa', component: bar path: 'aaa', component: bar
}] }]
}, },

View File

@@ -12,8 +12,17 @@
export default { export default {
methods:{ methods:{
getzhi(){ getzhi(){
// let a = "小梦"
// let b = 18;
// // let str = "名字是" + a + "年龄是" + b
// // 模板字符串
// let str = `名字是${a}年龄是${b}`
// console.log(str)
// 如何获取url传值 // 如何获取url传值
let zhi = this.$route.query // params 传参的时候 不在url显示 刷新之后丢失了
let zhi = this.$route.params
console.log(zhi) console.log(zhi)
} }
} }

View File

@@ -4,8 +4,6 @@
<el-menu <el-menu
default-active="2" default-active="2"
class="el-menu-vertical-demo menu" class="el-menu-vertical-demo menu"
@open="handleOpen"
@close="handleClose"
> >
<el-menu-item index="2" @click="toindex"> <el-menu-item index="2" @click="toindex">
<i class="el-icon-menu"></i> <i class="el-icon-menu"></i>
@@ -31,10 +29,15 @@ export default {
this.$router.push("/index") this.$router.push("/index")
}, },
tobar(){ tobar(){
// "/index/bar" path
this.$router.push("/index/bar") this.$router.push("/index/bar")
}, },
tofoo(){ tofoo(){
this.$router.push("/index/foo") // { name } 才是用name跳转
// params 使用这个方式传值 必须使用命名路由 用path跳转传不过去
// this.$router.push({ path:"/index/foo",params:{name:"111"} })
this.$router.push({ name:"foo",params:{name:"aaaa",age:18} })
} }
}, },
}; };