SoAanyip / React-FileUpload

Upload files async with xhr2 or iframe for IE. Supporting IE8+. React component.
310 stars 95 forks source link

为什么修改state没效果?rate #48

Open q1457797371 opened 7 years ago

q1457797371 commented 7 years ago

` render() { console.log(this); console.log("===");

return (

  <div className="page2-page">
    <PageHead title="导入历史订单" description="xxxx。"/>
    <Tab defaultActiveKey="taobao-import" onChange={this.handleChange}>
      {
        tabs.map(item => <TabPane key={item.key} tab={item.tab}
                                  onClick={this.handleClick}></TabPane>)
      }
    </Tab>
    <DownLoadItem/>
    <div className="title">
      第二步: 上传历史订单
    </div>
    <div className="content">
      <FileUpload options={this.uploadOptions}>
        <p>You have uploaded {this.state.rate}</p>
        <Button ref="chooseAndUpload" type="primary">选中文件</Button>
      </FileUpload>

    </div>

  </div>
);

} ` 为什么当上传的时候,this.state.rate没有值?不会变化为什么?

uploading: function (progress) { console.log(this) let rate = progress.loaded / progress.total + '%'; this.setState({rate}) console.log('loading...', rate) message.error(Upload failed,) }