Html 显示:无和可见性:隐藏不工作
我不明白为什么这不起作用,所以请帮我弄清楚 Display.js: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&
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';
}