#1333·mitosis

错误: 带数据的插槽

作者: Marvin-Brouwer创建于 2024年1月19日更新于 2025年11月17日

I need a slot in a list where I can pass around the data of its parent. For example, with a component like this:

javascript
import { Slot, Layout, For } from "@builder.io/mitosis";

export default function MyComponent(props) {
  const example = [ 
    "asdf",
    "dsfdsdf"
  ]

  return (
    <div>
      
      <For each={example} >
        {
          (item) => (
            <Slot name={props.slotPage} item={item}></Slot>
          )
        }
      </For>
    </div>
  );
}
In Vue, you can do: `<slot name="page" :item={item}></slot>`, however I can't seem to figure out how to make mitosis do this. The documentation doesn't state this as a gotcha, but it also doesn't state how to do this. If I need to make a feature request for this, please just tell me and close the ticket.

内容来源: BuilderIO/mitosis