Skip to content

Commit 582d26a

Browse files
authored
doc: Update vue.md (#962)
1 parent 0cb2ec7 commit 582d26a

File tree

1 file changed

+4
-42
lines changed

1 file changed

+4
-42
lines changed

docs/vue.md

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -841,51 +841,13 @@ export default router
841841
### 3.路由的query
842842

843843
```html
844-
<template>
845-
<div>
846-
<ul class="list">
847-
<!-- to的对象写法 -->
848-
<li v-for="item of data" :key="item.id">
849-
<router-link
850-
class="link"
851-
:to="{
852-
path:'/home/message/mes',
853-
query: { id:item.id, title:item.mes }
854-
}"
855-
>{{item.mes}}</router-link>
856-
</li>
857-
</ul>
858-
<hr>
859-
<router-view></router-view>
860-
</div>
861-
</template>
862-
863-
<script>
864-
export default {
865-
name:'HomeChild1',
866-
data() {
867-
return {
868-
data:[
869-
{id:1,mes:"消息1"},
870-
{id:2,mes:"消息2"},
871-
{id:3,mes:"消息3"}
872-
]
873-
}
874-
},
875-
}
844+
<script setup>
845+
import { useRoute } from 'vue-router';
846+
const route = useRoute();
876847
</script>
877-
878-
<style scoped>
879-
.list { margin-left:80px; }
880-
.link{
881-
color: orange;
882-
text-decoration: none;
883-
background-color: skyblue;
884-
}
885-
</style>
886848
```
887849

888-
> 接收参数 `{{$route.query.id}}`
850+
> 接收参数 `{{route.query.id}}`
889851
890852
#### 跳转路由并携带参数
891853

0 commit comments

Comments
 (0)