美文网首页
41_路由模式

41_路由模式

作者: CHENPEIHUANG | 来源:发表于2018-02-23 22:27 被阅读0次
    <!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_路由模式

          本文链接:https://www.haomeiwen.com/subject/ggjfxftx.html