我有一個項目清單。項目是從 API 動態獲取的,需要顯示在<select/> 我正在使用語義 ui 反應組件中。options 接受以下形式的對象: { key: "", text: "", value: "" } 這是表格:<Form size="large"> <Form.Select fluid label="Application Name" name="appName" onChange={(event) => fetchHandler(event)} options={} --> Item to be passed /></Form>這是我嘗試過的:這里的選項是響應,我正在將一個項目添加 appName到列表中appNames。let appNames = [];options.map((value) => { value.map((app) => { return appNames.push(app.appName); });});const appNameHandler = () => { let appOptions = [ { key: '', text: '', value: '', }, ]; for (let key = 0; key >= appNames.length; key++) { appOptions.push(...appNames, { key: key, text: appNames, value: appNames, }); } console.log(appOptions); return appOptions;};有沒有更好的解決方法?
如何使用 Semantic UI React 將數據傳遞到 <Form.Select>
qq_笑_17
2022-12-22 09:55:35