路由传值

This commit is contained in:
theluyuan 2021-07-06 16:44:22 +08:00
parent 727a943474
commit 40784994d1
2 changed files with 19 additions and 3 deletions

View File

@ -1,6 +1,7 @@
<template> <template>
<div>这是foo <div>这是foo
<router-link to="/bar">到bar</router-link> <router-link to="/bar">到bar</router-link>
<button @click="getzhi">获取传值</button>
</div> </div>
</template> </template>
<style scoped> <style scoped>
@ -8,6 +9,12 @@
</style> </style>
<script> <script>
export default { export default {
methods:{
getzhi(){
// url
let zhi = this.$route.query
console.log(zhi)
}
}
} }
</script> </script>

View File

@ -3,6 +3,15 @@
这是首页 这是首页
<!-- 不能用a标签 --> <!-- 不能用a标签 -->
<!-- <a href="/foo">到foo</a> --> <!-- <a href="/foo">到foo</a> -->
<router-link to="/foo">到foo</router-link> <!-- <router-link to="/foo">到foo</router-link> -->
<button>用js跳转</button>
<router-link :to="{path:'/foo',query:{name:123,age:234,asda:1411}}">到foo</router-link>
</div> </div>
</template> </template>
<script>
export default {
methods:{
}
}
</script>