在反应中,我有这样的成分:
const Title = ({ children }) => {
return <h2>{children}</h2>
}
export default Title我可以很容易地用它作为<Title>Something</Title>
在Qwik中,我可以创建相同的组件:
import { component$ } from '@builder.io/qwik'
const Title = component$(({ children }) => {
return <h2>{children}</h2>
})
export default Title但是<Title>Something</Title>不起作用。甚至<Title children='Something' />也不起作用。但是,如果我将道具名更改为text,那么<Title text='Something' />就能工作。
然而,在实际应用程序中,必须具备嵌套组件并以特殊名称重用它们的能力。
我怎样才能让孩子们在Qwik?
发布于 2022-11-22 02:42:01
Qwik用插槽代替孩子
import { component$, Slot } from '@builder.io/qwik'
const Title = component$(() => {
return <h2><Slot /></h2>
})
export default Titlehttps://stackoverflow.com/questions/74414072
复制相似问题