Reactjs 如何在物料界面中设置LinearProgress的最大值?
我在我的页面中使用的是MaterialUI中的LinearProgress,我的LinearProgress的最大值不是一直都是100,有时可能是10、20、5。我试过了Reactjs 如何在物料界面中设置LinearProgress的最大值?,reactjs,material-ui,Reactjs,Material Ui,我在我的页面中使用的是MaterialUI中的LinearProgress,我的LinearProgress的最大值不是一直都是100,有时可能是10、20、5。我试过了 <LinearProgress variant="determinate" value={section.Remaining_Qty} maxValue={50} // added />
<LinearProgress
variant="determinate"
value={section.Remaining_Qty}
maxValue={50} // added
/>
但它不起作用。还有其他方法吗?在值属性中使用此公式:
Math.round((100 / maxValue) * currentValue)
在值属性中使用此公式:
Math.round((100 / maxValue) * currentValue)
您可以使用公式来获得maxValue={100}的动态值,并且动态maxValue为10,20,5 最终代码 dynamicMaxValue=5和section.剩余数量=2的值将为=40%
记住section.Remaining_Qty您可以使用公式获得maxValue={100}的动态值,并且动态maxValue为10,20,5 最终代码 dynamicMaxValue=5和section.剩余数量=2的值将为=40%
请记住。我还没有尝试过,但我相信它会成功的,谢谢!我还没有试过,但我相信它会成功的,谢谢!