vue-6 局部组件化和全局组件化

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>vue</title>
    </head>
    <body>
        <div id="app"></div>
        <script src="https://vuejs.org/js/vue.js"></script>
        <script>
            // 局部组件
            var Myheader = {
                template:`
                    <div>我是头部</div>
                `
            }
            var Mybody = {
                template:`
                    <div>身体</div>
                `
            }
            //全局组件
            Vue.component('Myfoot',{
                template:`
                    <div>底部</div>

            })

            new Vue({
                el:"#app",
                components:{
                    Myheader,
                    Mybody
                },
                template:`
                    <div>
                        <Myheader></Myheader>
                        <Mybody></Mybody>
                        <Myfoot></Myfoot>
                    </div>
                `,
                data:function(){
                    return {

                    }
                }


            })
        </script>
    </body>
</html>
发表评论 / Comment

用心评论~