組件的內容分發

組件標籤的內容取出來使用: html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vue.js"></script>

</head>

<body>
<div id="app">
    <neirong>這是組件內容
        <ul slot="s1">
            <li>aaaaaaa</li>
        </ul>



        <ol slot="s2">
            <ul>
                bbbbb
            </ul>
        </ol>

    </neirong>
</div>

<template id="neirong">
    <div>
        <slot name="s2"></slot>
        <h1>sdfasf</h1>
    </div>
</template>


</body>

<script>

    new Vue({
        el: "#app",
        components:{
            'neirong':{
                template: "#neirong"
            }
        }
    })


</script>
</html>
相關文章
相關標籤/搜索