mocheng / react-and-redux

《深入浅出React和Redux》代码

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

第四章的todoList示例程序勾选框没有被正确渲染

CurryTang opened this issue · comments

todo
如图,左侧的勾选框没有被渲染出来,想请教一下是什么问题?与react版本有关嘛?
这是书中的源代码,看上去并没有问题

const TodoItem = ({onToggle, onRemove, completed, text}) => {
  const checkedProp = completed ? {checked: true} : {checked: false};
  return (
    <li
      className="todo-item"
      style={{
        textDecoration: completed ? 'line-through' : 'none'
      }}
    >
      <input className="toggle" type="checkbox" {...checkedProp} onClick={onToggle} />
      <label className="text">{text}</label>
      <button className="remove" onClick={onRemove}>×</button>
    </li>
  )
}
commented

请问解决了吗?我也遇到了相同的问题。

commented

仍没有解决

commented

样式问题,在.todo-item .toggle 里加上width好了
{ height: 40px; width: 100%; -webkit-appearance: none; appearance: none; position: absolute; top: 0; bottom: 0; }

commented