父子组件创建

<body>
    <div id="app">
        <father></father>
    </div>
    <script>
        // 创建一个fahter组件
        Vue.component('father', {
            template: `<div>我是父组件,<son></son></div>`,
            // 通过components属性创建子组件
            components: {
                // 创建一个son组件
                son: {
                    template: `<span>我是子组件</span>`
                }
            }
        })
        var vm = new Vue({
            el: '#app',
            data: {
            }
        })
    </script>
</body>

猜你喜欢

转载自blog.csdn.net/weixin_42442123/article/details/85764453
今日推荐