我试图使用react-beutiful-dnd,它接受字符串作为它的组件ID。当我使用<Droppable droppableId={this.props.id.toString()}>
时,它会返回错误:
TypeError: Cannot read property 'toString' of undefined
//App.js
//...
render(){
return(
<AppsComponent id={1} />
//...
//AppsComponent.js
//...
render(){
return(
<Draggable key={this.props.id.toString()} draggableId={this.props.id.toString()}>
//...
&#13;
为什么?
答案 0 :(得分:0)
试试没有toString
:
<Droppable droppableId={'droppable-' + this.props.id}>
例如:
var n = 5;
console.log("a = " + n); // a = 5
答案 1 :(得分:0)