router的安装和基本配置

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <div>
        <router-link to="/">首页</router-link>
        <router-link to="/about">关于我们</router-link>
    </div>
    <div>
        <router-view></router-view>
    </div>
</div>
<script src="../../lib/vue.js"></script>
<script src="../../lib/vue-router.js"></script>
<script src="js/main.js"></script>
</body>
</html>
var routes = [
    {
        path:"/",
        component:{
            template:`
            <div>首页</div>
            `
        }
    },
    {
        path:"/about",
        component:{
            template:`
            <div>关于我们</div>
            `
        }
    }
];

var router = new VueRouter({
    routes:routes
});
new Vue({
    el:"#app",
    router:router
})

 

posted @ 2018-01-30 21:23  一石数字欠我15w!!!  阅读(232)  评论(0编辑  收藏  举报