Closed sunmingtao closed 4 years ago
Command line
npm install --save vue-router
main.js
import VueRouter from 'vue-router'; Vue.use(VueRouter); import HomePage from './components/Home.vue' import AdminPage from './components/Admin.vue' const routes = [ { path: '/', component: Home, props: {msg: 'Age pension calculation'} }, { path: '/admin', component: Admin }, ] const router = new VueRouter({ mode: 'history', routes: routes }) new Vue({ router: router, render: h => h(App), }).$mount('#app')
App.vue
<div id="app"> <router-link to="/">Go to Home</router-link> <router-link to="/admin">Admin</router-link> <router-view></router-view> </div>
Command line
npm install --save vue-router
main.js
App.vue