【问题标题】:Why is Progressbar from react-bootstrap not working?为什么 react-bootstrap 的 Progressbar 不起作用?
【发布时间】:2021-04-04 10:53:10
【问题描述】:

我正在使用 React 引导库中的 ProgressBar,我不知道为什么它不能正常工作

这是代码

<div>
 <p>{selectedOption_1 ? <span><b>Your Choice</b> &#128073; &nbsp;</span> : null}  {props.location.state.option1}</p>
 <p style={{fontSize: "small"}}>Votes: {props.location.state.optionOneVotes}  </p>
 <ProgressBar now={optionOnePercentage} animated variant="warning" striped label={`${optionOnePercentage}%`} />
 </div>

即使我传递了硬编码的值,结果也是一样的

<ProgressBar now={60} />
<ProgressBar now='60' animated variant="warning"  />

【问题讨论】:

    标签: css reactjs progress-bar react-bootstrap


    【解决方案1】:

    尝试传递一个常量值并测试它是否有效

    问题可能是你试图从 props 或 state 传递 optionOnePercentage 而你忘记写了

    由于没有太多代码问题可以在任何地方

    编辑 1

    尝试包括

    import 'bootstrap/dist/css/bootstrap.min.css'
    

    如果您使用 npx create-react-app 创建了应用程序,则在 index.js 文件中

    【讨论】:

    • 我已经编辑了我的问题,我希望它现在被清除了
    • 你导入引导文件了吗?我试过你的代码它没有显示进度条,然后我安装了'bootstrap'并将它包含在 index.js 它工作
    • 是的,我已经在 index.js 中添加了这一行,但问题仍然存在。如果你打开我附上的图片,上面的进度条是0,下面的进度条是100%你可以看到顶部有一条很小的黄线,我不知道为什么会这样
    猜你喜欢
    • 2022-11-13
    • 1970-01-01
    • 2021-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-22
    • 2023-01-20
    • 2017-07-08
    相关资源
    最近更新 更多