小试牛刀
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="../vue.js"></script> <script src="../vue-router.js"></script> <style> .router-link-active { color: red } </style> </head> <body> <div id="app"> <p> <router-link to="/foo">Go to Foo</router-link> <router-link to="/bar">Go to Bar</router-link> </p> <router-view> </router-view> </div>
</body>
<script>
const Foo = {template: '<div>foo</div>'};
const Bar = {template: '<div>bar</div>'};
const router = new VueRouter({
routes: [
{path: '/foo', component: Foo},
{path: '/bar', component: Bar}
]
});
const app = new Vue({
router
}).$mount('#app')
</script>
</html>