完善路由
This commit is contained in:
parent
14a47ff98d
commit
c23309ca81
@ -158,3 +158,10 @@ const router = createRouter({
|
|||||||
const app = createApp();
|
const app = createApp();
|
||||||
app.use(router); // 在应用使用router
|
app.use(router); // 在应用使用router
|
||||||
```
|
```
|
||||||
|
显示路由及跳转
|
||||||
|
```vue
|
||||||
|
<template>
|
||||||
|
<router-view />
|
||||||
|
<router-link to="要跳转的路径"></router-link>
|
||||||
|
</template>
|
||||||
|
```
|
@ -3,10 +3,7 @@
|
|||||||
<h1>vue3 + vite + {{ username }} {{ currentPath }}</h1>
|
<h1>vue3 + vite + {{ username }} {{ currentPath }}</h1>
|
||||||
<input type="text" v-model="username">
|
<input type="text" v-model="username">
|
||||||
|
|
||||||
<template v-if="currentPath == '/home'">
|
<router-view />
|
||||||
<Home/>
|
|
||||||
</template>
|
|
||||||
<User v-if="currentPath == '/user'"/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<h1>Home</h1>
|
<h1>Home</h1>
|
||||||
<a href="#/user">User</a>
|
<router-link to="/user">User</router-link>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<h1>User</h1>
|
<h1>User</h1>
|
||||||
<a href="#/home">Home</a>
|
<router-link to="/home">Home</router-link>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user