小工具知识网

当前位置: 首页 > 行业知识 > 微信小程序 - 组件wxml中slot

行业知识

微信小程序 - 组件wxml中slot

2026-11-14 00:17:34 来源:互联网转载

在���件的 wxml 中可以包含 slot 节点,用于承载组件使用者提供的 wxml 结构。

()

默认情况下,一个组件的 wxml 中只能有一个 slot 。需要使用多 slot 时,可以在组件 js 中声明启用。

Component(    options: {        multipleSlots: true // 在组件定义时的选项中启用多slot支持    }    properties: { /* ... */ },    methods: { /* ... */ })

此时,可以在这个组件的 wxml 中使用多个 slot ,以不同的 name 来区分。

()
    这里是组件的内部细节  

使用时,用 slot 属性来将节点插入到不同的 slot 上。

          这里是插入到组件slot name="before"中的内容        这里是插入到组件slot name="after"中的内容  组件样式

上一篇:轻量服务器怎么远程开机?

下一篇:电脑怎么自己搭建服务器?