Currently exploring Vue JS and running into difficulties with routers. I want specific content to display when entering a certain page address, such as "Home". For instance, I have a component named HomePage
, and I desire for this component to appear when the URL contains "Home", like "http://localhost:8080/Home". If no specific address is provided, then an empty page should be displayed.
App.vue
<template>
<HomePage></HomePage>
</template>
<script>
import HomePage from "@/View/HomePage/HomePage";
export default {
name: 'App',
components: {
HomePage
}
}
</script>
Edit
App.vue
<template>
<HomePage>
<router-view />
</HomePage>
</template>
<script>
import HomePage from "@/View/HomePage/HomePage";
export default {
name: 'App',
components: {
HomePage,
}
}
</script>
Index.js
import Vue from 'vue'
import Router from 'vue-router'
import HomeRoute from '@/components/routes/HomeRoute'
import Rar from "./src/View/Rar";
Vue.use(Router)
const router = new Router({
routes: [
{
path: '/home',
name: 'HomeRoute',
alias: '*',
component: HomeRoute
},
{
path: '/Rar',
name: 'Rar',
component: Rar
}
]
})
export default router