目录

slot Tag in the Component HXML File

The slot tag in a component HXML file is used to pass the child node content provided by the component user.

If multiple slot tags are defined, use different names to distinguish them.

<!-- Component template -->
<view class="custom">
  <slot name="header"></slot>
  <view>Internal details of the component</view>
  <slot name="footer"></slot>
</view>

Use the properties of the slot tag to insert nodes into the slot tags.

<!-- Page template that references a component -->
<view>
  <my-component>
    <!-- Content in the position of the <slot name="header"> tag -->
    <view slot="header">Content inserted into the <slot name="header"> tag</view>
    <!-- Content in the position of the <slot name="footer"> tag -->
    <view slot="footer">Content inserted into the <slot name="footer"> tag</view>
  </my-component>
</view>