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

Vue2.0路由学习探索总结---get-started

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

先直观体验一把


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="app">yes
<h2>Router Basic - 02</h2>
<router-link to="{ path: '/home'}">Home</router-link>
<router-link to="{ path: '/about'}">About</router-link>
<router-view></router-view>
</div>
<template id="home">
<div>
<h1>Home</h1>
<p>{{msg}}</p>
</div>
<div>
<ul class="nav nav-tabs">
<li>
<a v-link="{ path: '/home/news'}">News</a>
</li>
<li>
<a v-link="{ path: '/home/message'}">Messages</a>
</li>
</ul>
<router-view></router-view>
</div>
</template>
<template id="news">
<ul>
<li>News 01</li>
<li>News 02</li>
<li>News 03</li>
</ul>
</template>
<template id="message">
<ul>
<li>Message 01</li>
<li>Message 02</li>
<li>Message 03</li>
</ul>
</template>
<template id="about">
<div>
<h1>About</h1>
<p>This is the tutorial about vue-router.</p>
</div>
</template>
</body>
<script src="../vue.js"></script>
<script src="../vue-router.js"></script>
<script>
const Home = {
template: '#home',
data: function () {
return {
msg: 'Hello, vue router!'
}
}
};
var News = {
template: '#news'
};
var Message = {
template: '#message'
};
var About = {
template: '#about'
};
const router = new VueRouter({
routes: [
{
path: '/',
redirect: '/home',
        },
        {
            path: '/home', component: Home,
            children: [
                {path: '/news', component: News},
                {path: '/message', component: Message},

            ]
        },
        {
            path: '/about', component: About
        }
    ]
});
const app = new Vue({router}).$mount('#app')

</script>

</html>

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