1. 程式人生 > >插槽slot

插槽slot

body ont oct scrip emp wid nbsp 頭部 com

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .panel{
            max-width: 300px;
            border:1px solid #999;
            margin-bottom: 15px;
        }
        .panel>*{
            padding
: 15px; } .panel .title{ border-bottom: 1px solid #999; } .panel .footer{ border-top: 1px solid #999; } </style> </head> <body> <div id="app"> <panel><div slot="title">我是你大爺</div><div slot
="content">xxxxxxxxxxxx</div></panel> <panel><div slot="content">yyyyyyyyyyyy</div></panel> <panel><div slot="content">zzzzzzzzzzzz</div><div slot="footer">我是你二大爺</div></panel> </div> <template id="panel-tpl"> <
div class="panel"> <div class="title"> <slot name="title">默認的頭部信息</slot> </div> <div class="content"> <slot name="content">默認的主體內容</slot> </div> <div class="footer"> <slot name="footer">默認的尾部信息</slot> </div> </div> </template> <script src="../lib/vue.js"></script> <script src="js/main.js"></script> </body> </html>
Vue.component("panel",{
    template:"#panel-tpl"
});

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

    }
})

插槽slot