首页 > 解决方案 > material-ui react.js 中带有评级值的错误

问题描述

我有 3 组不同的评级,它们都需要独立。该错误是当单击其中一个评级时,只有第一组(首先呈现)评级发生变化。这意味着所有不同的评级集之间似乎存在联系。

在此处输入图像描述

与此错误有关的主要部分是名为 AssetName 的方法。

function AssetName(props) {
  let localAssetName = [];
  let streamHolder = [];
  let holder = [];

  localAssetName.push("Asset 1");
  localAssetName.push("Asset 2");
  localAssetName.push("Asset 3");
  localAssetName.push("Asset 4");
  localAssetName.push("Asset 5");
  localAssetName.push("Asset 6");

  // this.setState({ assetNameAr : localAssetName});
  // this.setState({assetTest: true})
  props.parentCallback(localAssetName);
  let displasset = function displfcn() {
    for (let i1 = 0; i1 < localAssetName.length; i1++) {
      holder.push(
        <Grid container spacing={10}>
          <Grid item>
            <Box> {localAssetName[i1]}</Box>
          </Grid>
          <Grid item p={10} ml={10}>
            {/* Technical Expertise */}
            {/* <AssetLoop len ='1'/> */}
            <Rating max={3}> </Rating>
          </Grid>

          <Grid item p={10} ml={10}>
            {/* Business Knowledge */}
            {/* <AssetLoopBN len ='1'/> */}
            <Rating max={3}> </Rating>
          </Grid>

          <Grid item>
            {/* How recently have you worked on this asset? */}
            {/* <AssetLoopREC len = '1'/> */}
            <Rating max={4}> </Rating>
          </Grid>
        </Grid>
      );
    }
  };
  displasset(localAssetName);
  return holder;
}

标签: javascriptreactjswebmaterial-ui

解决方案


Rating 的“name”属性必须是唯一的。 Material ui 的 github 上的类似问题


推荐阅读