Vue2.0在组件中定义和使用子组件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>定义子组件</title>
</head>
<body>
<script src="vue2.513.js"></script>
</body>
<div id="app">
<account></account>
</div>
<script>
    //定义一个账号组件
    Vue.component('account',{
        template:'<div><h1>账号组件</h1><login></login></div>',//在这里使用登录组件
        //在账号组件中定义一个登录的子组件
        components:{
            'login':{
                template:'<h2>登录子组件</h2>'
            }//组件的名字就叫做login
        }

    })
    new Vue({
        el:'#app',
    });
</script>
</html>

猜你喜欢

转载自blog.csdn.net/weixin_40593587/article/details/79293463