我有一個對象數組,它們有一個 key Component,它指向其各自的組件。我能夠映射數組并顯示所有組件,如下所示,dict.map(({ Component }) => <Component />這可行,但是我正在嘗試有條件地渲染特定組件。就我而言,我試圖訪問Componentindex 處的屬性1,但它似乎不起作用。我嘗試訪問它的方式類似于,,dict[displayComponentAtIndex].Component其中displayComponentAtIndex是狀態的一部分。如何按照我想要的方式渲染組件?
如何根據選定的索引動態訪問和渲染數組中的組件?
偶然的你
2023-07-14 09:59:22