07 匿名插槽

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <App></App>
</div>
<script src="./vue.js"></script>
<script>
    Vue.component('Mbtn',{
        template: `
               <btton>
                    //无需多个槽
                    <slot></slot>
                </btton>>`
    })

    const App = {
        data(){
            return {
                title:'老爸'
            }
        },
        template:`
                <div>
                    <Mbtn><a href="#">登录</a></Mbtn>
                    <Mbtn>注册</Mbtn>
                </div>`,

    }

    new Vue({
        el:'#app',
        data:{

        },
        components:{
            //2.挂载子组件
            App
        }
    })

</script>
</body>
</html>
posted @ 2020-12-28 17:16  *!Walter!*  阅读(62)  评论(0编辑  收藏  举报