<html> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Vue</title> <script src="https://www.hxstrive.com/cdn/libs/vue/2.7.16/vue.min.js"></script> </head> <body> <div id="app"> <base-layout> <!-- 这是提供给名为 header 插槽的默认值 --> <template v-slot:header> <h1>Here might be a page title</h1> </template> <!-- 默认插槽,名为 default 插槽的默认值 --> <p>A paragraph for the main content.</p> <p>And another one.</p> <!-- 这是提供给名为 footer 插槽的默认值 --> <template v-slot:footer> <p>Here's some contact info</p> </template> </base-layout> </div> <script type="text/javascript"> Vue.component('base-layout', { template: ` <div> <header style="background:red;"> <slot name="header"></slot> </header> <main style="background:green;"> <slot></slot> </main> <footer style="background:blue;"> <slot name="footer"></slot> </footer> </div> ` }); var app = new Vue({ el: "#app", data: {} }); </script> </body> </html>
在线代码编辑器
HTML / CSS / JavaScript 实时预览
更多工具
运行
保存
自动执行
模板
JS 库
清空
主题
代码编辑区
字符数: 0
提示: 输入完整的 HTML 代码,需包含 DOCTYPE 声明与 html 根标签
预览效果
选择模板
取消
选择库和版本
库
版本
文件
取消
已复制到剪贴板