Skip to main content
Version: 3.x

Slot

slot 插槽

支持情况:

类型

ComponentType<SlotProps>

示例代码

import { Slot, View, Text } from '@tarojs/components'

export default class SlotView extends Component {
render () {
return (
<View>
<custom-component>
<Slot name='title'>
<Text>Hello, world!</Text>
</Slot>
</custom-component>
</View>
)
}
}

SlotProps

参数类型默认值必填说明
namestringnone指定插入的 slot 位置
varNamestringnonescoped slot 传入数据源

API 支持度

API微信小程序百度小程序支付宝小程序字节跳动小程序QQ 小程序京东小程序H5React Native
SlotProps.name✔️✔️✔️✔️✔️✔️
SlotProps.varName✔️