<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>vue-route使用</title>
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script src="./vue.js"></script>
<script src="./vue-router.js"></script>
</head>
<body>
<div id="app">
<nav class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
<img src="https://static.shiyanlou.com/img/logo_03.png" alt="" height="50">
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><router-link to="home">首页</router-link></li>
<li><router-link to="courses">项目</router-link></li>
<li><router-link to="paths">路径</router-link></li>
<li><router-link to="bootcamp">博客</router-link></li>
</ul>
</div>
</div>
</nav>
<div class="container">
<router-view></router-view>
</div>
<script>
const Home = { template: '<div><h1>首页</h1></div>' }
const Courses = { template: '<div><h1>项目</h1></div>' }
const Paths = { template: '<div><h1>路径</h1></div>' }
const Bootcamp = { template: '<div><h1>博客</h1></div>' }
var router = new VueRouter({
routes: [
{ path: '/home', component: Home },
{ path: '/courses', component: Courses },
{ path: '/paths', component: Paths },
{ path: '/bootcamp', component: Bootcamp }
]
})
const app = new Vue({
router
}).$mount('#app')
</script>
</body>
</html>