<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>在Vue中使用插槽(solt)</title>
    <script src="./vue.js"></script>
</head>
<body>
    <div >
        <body-content>
            <!--具名插槽的使用(可以使用多个)-->
            <!--<div class="header" slot="header">header</div>-->
            <div class="footer" slot="footer">footer</div>
        </body-content>
    </div>
    <script>
        Vue.component('body-content',{
            template:'<div>' +
                        '<slot name="header">可以在这添加些内容</slot>'+
                        '<div class="content">content</div>'+
                        '<slot name="footer"></slot>'+
                     '</div>'
        });
        var vm = new Vue({
            el:'#root'
        })
    </script>
</body>
</html>

 

相关文章:

  • 2022-01-20
  • 2021-11-24
  • 2021-09-24
  • 2021-05-31
  • 2021-12-04
  • 2021-04-23
猜你喜欢
  • 2022-12-23
  • 2021-07-19
  • 2021-08-27
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2022-12-23
相关资源
相似解决方案