<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>21-vue中使用插槽</title> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <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 app = new Vue({ el:'#app', }) </script> </body> </html>
16-vue中使用具名插槽
猜你喜欢
转载自www.cnblogs.com/suni1024/p/11540275.html
今日推荐
周排行