javascript - 模态 - 保持默认值

标签 javascript html twitter-bootstrap reactjs bootstrap-modal

我正在使用 Bootstrap 和 React 创建一个模态。

在其中,我有一个下拉列表,其中有一个空元素作为其第一个选项:

<select class="form-control" onChange={this.handleSelectCat}>
    <option disabled selected></option>
    <option>A</option>
    <option>B</option>
    <option>C</option>
    <option>D</option>
</select>

enter image description here

如果我选择一个选项:

enter image description here

如果我关闭模态,当我打开它时,我会得到之前选择的选项作为我的默认值。

enter image description here

如何使每次打开模态时默认为空选项?

最佳答案

在关闭模式时,触发一个方法来重置下拉列表的选择。

关于javascript - 模态 - 保持默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33783455/

相关文章:

javascript - 从 github url 中查找用户、repo 和路径

html - 如何居中未知宽度的[图像+文本]?

html - 解决 IE 怪癖模式下的渲染错误

python - 从 Bootstrap <button> 接收 HTML 请求

javascript - 纯函数: state content vs.状态引用

javascript - Angular CLI 是否使用 SystemJS?

html - 按钮文本位置与浏览器不同

twitter-bootstrap - Bootstrap 4.1 中的 bd-highlight 是什么?

twitter-bootstrap - Bootstrap 模式中的数据表固定标题不起作用

javascript - 如何停止悬停过渡中元素的重叠?