Last active
April 9, 2017 14:50
-
-
Save antoniojps/c05098e048099d904414f91b3abff648 to your computer and use it in GitHub Desktop.
Vue Router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment