React Component不会触发onClick

时间:2016-10-22 04:00:31

标签: reactjs

我有一个React button组件,在点击时不会触发onClick事件。我添加了一个:active CSS选择器,以确保它已启用并可单击。奇怪的是,它旁边的onChange上的input处理程序工作正常。有什么想法吗?

return (
  <ul className="horizontal">
    <li className="adjustInput">
      <label>
        <input max={200} min={10} onChange={e => actions.onAdjustSize(e.target.value)} type="range" value={size} />
        Image Size: {size}%
      </label>
    </li>
    <li className="adjustInput">
      <label>
        <input max={OPACITY_MULTIPLIER} min={OPACITY_MULTIPLIER / 10} onChange={e => {actions.onAdjustOpacity(e.target.value / OPACITY_MULTIPLIER)}} type="range" value={opacity} />
        Opacity: {opacity}%
      </label>
    </li>
    <li className="adjustInput">
      <label>
        {/* This onChange is fired when I type in the input */}
        <input onChange={actions.onRemove} type="text" />
        {/* This onClick isn't fired no matter what I try */}
        <button onClick={actions.onRemove}>Remove</button>
      </label>
    </li>
  </ul>
);

Image of UI rendered by code above

我显然已经尝试用鼠标点击按钮了。我也尝试过它并按下空格键和空格键。输入。手动触发JS中的单击。似乎没有任何作用:/

0 个答案:

没有答案