第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

把JavaScript表達式提取到外面后無法添加內容了

如題,就是無法添加以及獲取內容,也沒有什么報錯信息

import?React?from?'react';
import?TodoItem?from?'./TodoItem'
class?TodoList?extends?React.Component?{
constructor(props)?{
super(props)
this.state?=?{
list:?[],
inputValue:?''
}
this.handleBtnClick?=?this.handleBtnClick.bind(this)
this.handleInputChange?=?this.handleInputChange.bind(this)
}
//?增加內容
handleBtnClick()?{
this.setState({
list:?[...this.state.list,?this.state.inputValue],
inputValue:?''
})
}
//?輸入內容監(jiān)聽
handleInputChange(e)?{
this.setState({
inputValue:?e.target.value
})
}
//?刪除內容
handleDelete(index)?{
const?list?=?[...this.state.list]
list.splice(index,?1)
this.setState({
list:?list
})
}
//?獲取內容
getTodoItems()?{
this.state.list.map((item,?index)=>{
return?(
<TodoItem
deleteClick={this.handleDelete}
key={index}
content={item}
index={index}
/>
)
})
}
render()?{
????return?(
????????<div>
????????????<div>
????????????????<input?value={this.state.inputValue}?onChange={this.handleInputChange}?/>
????????????????<button?onClick={this.handleBtnClick}>Add</button>
????????????</div>
????????????<ul>{this.getTodoItems()}</ul>
????????</div>
????????);
????}
}
export?default?TodoList;



正在回答

1 回答

https://img1.sycdn.imooc.com//5c63d54e0001d3f407570508.jpg

如下圖:https://img1.sycdn.imooc.com//5c63d57800017bf708000281.jpg

1 回復 有任何疑惑可以回復我~
#1

Zz皓 提問者

我太粗心了,謝謝你的提醒
2019-02-13 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

把JavaScript表達式提取到外面后無法添加內容了

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號