Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 显示:无和可见性:隐藏不工作_Html_Css_Reactjs - Fatal编程技术网

Html 显示:无和可见性:隐藏不工作

Html 显示:无和可见性:隐藏不工作,html,css,reactjs,Html,Css,Reactjs,我不明白为什么这不起作用,所以请帮我弄清楚 Display.js: render(){ const notesList = this.props.notesList; const displayNotes = notesList.map( (note,note_id) => <div className="display"> <p id={'note-' + note_id}>{note}</p&

我不明白为什么这不起作用,所以请帮我弄清楚

Display.js:

render(){
    const notesList = this.props.notesList;
    const displayNotes = notesList.map( (note,note_id) =>
      <div className="display">
        <p id={'note-' + note_id}>{note}</p>
        <button type="button" className="edit-button" onClick={()=>this.props.edit(note_id)}>Edit</button>
        <button type="button" className="delete-button" onClick={()=>this.props.delete(note_id)}>Delete</button>
      </div> );

    return <div>{displayNotes}</div>;
  }
}

如果要更改元素css属性,需要首先访问样式对象

以下是您将获得它的方式:

  handleDelete = (note_id) => {
    const id = 'note-' + note_id;
    document.getElementById(id).style.display = 'none';
  }

element.style.display
就是你想要的。dom元素没有名为
display
的属性,此错误发生在您的
handleDelete()
  handleDelete = (note_id) => {
    const id = 'note-' + note_id;
    document.getElementById(id).style.display = 'none';
  }