Vue 路由功能

<div id="app">
        <router-link to="/login" tag="span">登陆</router-link>
        <router-link to="/register">注册</router-link>
        <router-view></router-view>

    </div>



    <script src="vue.js"></script>
    <script src="vue-resource.min.js"></script>
    <script src="vue-router.js"></script>
<script>
        var login={
            template:'<h1>登陆组件</h1>'
        };
        var register={
            template:'<h1>注册组件</h1>'
        };


        var vr=new VueRouter({
            routes:[
                {path:'/login',component: login},
                {path:'/register',component:register}
            ]
        });



        new Vue({
            el:'#app',
            data:{
                list:[
                    { id: Date.now(), user: '司马迁', content: '欲加之罪!' },
                    { id: Date.now()+1, user: '庄子', content: '水击千里!' },
                    { id: Date.now()+2, user: '刘庄', content: '美女很多!' }
                ]
            },
            router:vr

        })



</script>

猜你喜欢

转载自blog.csdn.net/weixin_43209953/article/details/86500306