继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

Vue2.0路由学习探索总结---simple-demo

resharpe
关注TA
已关注
手记 102
粉丝 7244
获赞 3476
Vue2.0路由学习探索总结---simple-demo

小试牛刀


<!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>

打开App,阅读手记
1人推荐
发表评论
随时随地看视频慕课网APP