簡體   English   中英

防止 JSON 對象在 ReactJS 中按字母順序排序

[英]Preventing JSON objects from ordering alphabetically in ReactJS

我遇到了一個問題,其中 JSON 自動按字母順序排列存儲的數據給我帶來了很多麻煩。

使用

    <FormControl component="fieldset">
      <FormLabel component="legend">Days of the Week</FormLabel>
      <FormGroup aria-label="position" row>
        {Object.keys(days).map(key => {
          return (
            <FormControlLabel
              key={key}
              checked={days[key]}
              onChange={event => changed({ [key]: event.target.checked })}
              control={<Checkbox color="primary" />}
              label={key}
              labelPlacement="top"
            />
          );
        })}
      </FormGroup>
    </FormControl>
  );

最后我的日子在周五、周一、周六、周日、周四、周二、周三被取代

我遇到了 C、Python 等類似問題的解決方案,但不幸的是,ReactJS 沒有遇到類似問題,任何幫助將不勝感激。

嘗試使用數組類型? 或者添加一個字段來標識訂單

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM