为了账号安全,请及时绑定邮箱和手机立即绑定

跟着视频敲的代码,但是input框里面输入不了东西,大家帮忙看看为啥

import React from 'react';

class TodoList extends React.Component {

    constructor(props){
        super(props);
        this.state={
            list:[],
            inputValue:''
        }
    }

    handleBtnClick(){
        this.setState({
            list:[...this.state.list,this.state.inputVlue],
            inputVlue: ''
        })
    }
    handleInputChange(e){
        this.setState({
            inputVlue:e.target.value
        })
    }

    render(){
        return (
            //jsx 语法
            <div>
                <div>
                    <input value={this.state.inputValue} onChange={this.handleInputChange.bind(this)}/>
                    <button onClick={this.handleBtnClick.bind(this)}>add</button>
                </div>
                <ul>
                    {
                        this.state.list.map((item,i)=>{
                          return <li key={i}>{item}</li>
                        })
                    }
                </ul>
            </div>
        );
    }

}

export default TodoList;


2019-07-08 源自:React16.4 快速上手 2-2 350 浏览 2 回答

单词写错了https://img1.sycdn.imooc.com/5d22e5cf00013b8806390262.jpg

2019-07-08
回复 1

qq_斷了D弦_03426429 (提问者)

牛逼!!!
#1 2019-07-08 回复

import  React,{Component} from 'react';


2019-07-20
回复 0

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信