<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
</head>
<body>
<div id="app">
<router-link to="/home">主页</router-link>
<router-link to="/about">关于</router-link>
<router-view></router-view>
</div>
<script src="vue.js"></script>
<script src="vue-router.js"></script>
<script>
const Home = {
template:"<div><h1>主页AAA</h1></div>"
}
const About = {
template:"<div><h1>关于BBB</h1></div>"
}
const router = new VueRouter({
mode: 'history',
routes:[
{
path:'/home',
component:Home
},
{
path:'/about',
component:About
}
]
})
var vm = new Vue({
el:"#app",
router
})
</script>
</body>
</html>
网友评论