首页 > 编程知识 正文

vue,vue插槽的使用

时间:2023-05-04 21:16:19 阅读:109019 作者:2207

插槽//App组件templatediv id='app'Testdivslot插槽占位符/div/test/div/templatescriptimporttestfrom ' @ test export default { components : { test }/script//test组件templatediv id='test'//定义插槽slot/sloth3这是test组件。app.vuetemplatedivid=' app ' testdiv slot=' header '这是头部/divdiv slot='footer '这是尾部/div/test/div/template sste script//test.vuetemplatedivid=' test ' slot name=' header '/sloth 3这是test。template v-slot//app.vuetemplatedivid=' app ' testtemplatev-slot=header H2 slot头部内容/h2/templatep直接插入组件内容/ptemplatev templatev export default { components : { test }/script//test.vuetemplatedivid=' test ' headerslotname=' header '/slot Sect

描述组件模板所需的slot插槽,并将当前组件的数据通过v-bind绑定到slot标记。

使用组件时,slot-scope=“scope "用于接收绑定到组件中的slot标记的数据。

您现在可以在scope.xxx中使用绑定数据

//app.vue divid=' app ' test//slot-scope作用域插槽div slot=' default ' slot-scope=' scope ' { { scope.msg } } /

divid=' app ' testtemplatev-slot : header=' scope '/v-slot定义作用域插槽div H3 slot/h3p { { scope.msg } }/p/div/v

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。