【发布时间】:2021-04-01 02:38:43
【问题描述】:
我希望在单击 “Let's GO” 按钮(位于 App.vue 中)后查看 uwc.vue 的内容。
但是,url 改变了,屏幕的内容仍然保持不变。
我是 vue 新手,我向 Vuetify 社区提出了这个问题,但被忽略了。
提前谢谢你。
router.js:
import Vue from 'vue';
import Router from 'vue-router';
import uwc from '../views/uwc';
Vue.use(Router);
export default new Router({
mode: 'history',
routes: [
{ path: '/', name: 'uwc', component: uwc},
]
});
App.vue
<template>
<v-app>
<v-container fluid>
<v-col class="d-flex mx-auto" >
<!-- UWC Card -->
<v-card class="mx-auto my-15" max-width="400" >
<v-img height="400px" class="image-fit" src="./img/UWC-logo.webp" ></v-img>
<v-divider class="mx-4"></v-divider>
<v-card-title>
<p class="text-break">
University of the Western Cape
</p>
</v-card-title>
<v-card-actions>
<router-link to="/views/uwc">
Let's GO
</router-link>
</v-card-actions>
</v-card>
</v-col>
</v-container>
</v-app>
</template>
<script>
export default {
name: 'app',
}
</script>
uwc.vue(我想在点击“Let's GO”按钮时显示的文件):
<template>
<v-app id="inspire">
<router-view></router-view>
<v-container fluid>
<v-row>
<template v-for="n in 4">
<v-col :key="n" class="mt-2" cols="12">
<strong> Category {{ n }} </strong>
</v-col>
<v-col v-for="j in 6" :key="`${n}${j}`" cols="6" md="2">
<v-sheet height="150"></v-sheet>
</v-col>
</template>
</v-row>
</v-container>
</v-app>
</template>
【问题讨论】:
-
您没有在 router.js
routes数组中定义路径 /views/uwc 的视图 -
感谢您的帮助。多亏了您和 Riza 的回答,问题才得以解决。
标签: vue.js vuetify.js vue-router router