23-基础-组件-局部组件

<!DOCTYPE html>
<html>

<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'>
        <h-p></h-p>
        <h-p></h-p>
        <h-p></h-p>
        <h-p></h-p>
    </div>
    <script src='./vue.js'></script>
    <script>
        new Vue({
            el: '#app',
            data: {
            },
            // 选项
            // 1. 定义
            // 2. 组件选项(template/data/methods等(除了el))
            // 3. 使用->自定义标签名
            components: {
                // 组件名:组件选项所在对象
                "h-p": {
                    template: `<div>我是h-p组件--{{msg}}</div>`,
                    data() {
                        return {
                            msg: "abc11"
                        }
                    }
                },
            },
            methods: {}
        });
    </script>
</body>

</html>

posted @ 2019-05-28 22:38  193557749  阅读(135)  评论(0编辑  收藏  举报