Vue Router
import Vue from "vue"
import App from "./App.vue";
import VueRouter from "vue-router";
import User from "./components/user/User.vue";
import Home from './components/Home.vue';
Vue.use(VueRouter);
const router = new VueRouter(
{
routes : [
{path:'',component: Home},
{path:'/user',component: User}
],
mode: 'history'
}
);
new Vue({
el: '#app',
router: router,
render: h => h(App)
});
// Componente
<template>
<ul class="nav nav-pills">
<router-link tag="li" to="/" active-class="active" exact><a>Home</a></router-link>
<router-link tag="li" to="/user" active-class="active"><a>User</a></router-link>
</ul>
</template>
// Mudar atraves de javascript
export default {
methods: {
nagivationToUser(){
this.$router.push('/user');
}
}
}