<!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>
41_路由模式
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 在前面的教程里,我们构建了一个简单的日志记录系统。我们已经能够向许多消费者传送日志消息啦。在本期,我们将会做一些修...