-
Notifications
You must be signed in to change notification settings - Fork 0
Using vue router
Julian Gojani edited this page Aug 27, 2020
·
2 revisions
npm install vue-router
/*...*/
import router from './router'
/*...*/
const app = new Vue({
router,
el: '#app'
});
import Vue from 'vue'
import VueRouter from 'vue-router'
import Homepage from '../views/Homepage.vue';
import About from '../views/About.vue';
Vue.use(VueRouter)
const routes = [
{
path: "/",
name: "Homepage",
component: Homepage
},
{
path: "/about",
name: "About",
component: About
}
]
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes: routes
})
export default router
<template>
<div>
<h1>Test</h1>
<router-link to="/about">About</router-link>
</div>
</template>
<script>
export default {
name: "Homepage"
}
</script>
<template>
<div>
<h2>About</h2>
</div>
</template>
<?php
/*...*/
$router->get("(.*)", "homepage.php");
$router->setPageNotFound("homepage.php");
/*...*/
Done!
npm run build