vue局部组件的使用

南笙酒味 提交于 2020-03-14 12:45:20
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <title>vue组件的使用</title>
    <style>
        body{
            color:burlywood;
        }
        .header{
            width: 100%;
            height: 40px;
            background-color: #333;
            line-height: 40px;
            text-align: center;
        }
    </style>
</head>
<body>
    <div id='app'></div>
    <script>
        // 1.声明组件
        var Vheader = {
            template : `
                <div class='header'>
                    头部区域
                </div>
            `,
        }
        new Vue({
            el:'#app',
            data(){
                return{

                }
            },
            // 3.使用组件
            template:`
                <Vheader/>
            `,
            // 2.挂载组件
            components:{
                Vheader,
            }
        })
    </script>
</body>
</html>

  

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!