我想了解為什么這段代碼的編譯版本無效<Fragment> {listData.list.description && ( <div> <div dangerouslySetInnerHTML={{ __html: list.description }} /> {hasTopCollection && <ImageAttribution />} </div> // ^ ) expected {list.listOptions.brandHeaderType === 20 && <SomeComponent />} // ^ Parsing error: Unexpected token, expected "," )}</Fragment>我listData.list.description && <Description>在父組件中有此組件,但現在我想將此邏輯移至實際<Description>組件中。所以在這之前是這樣的:<Fragment> <div> <div dangerouslySetInnerHTML={{ __html: list.description }} /> {hasTopCollection && <ImageAttribution />} </div> {list.listOptions.brandHeaderType === 20 && <SomeComponent />}</Fragment>
為什么這個 React 返回碼無效?(條件渲染)
小唯快跑啊
2022-12-22 12:15:15