插入video的时候,如果在视频上传成功之后,等待一会再点击确定,会插入很多个video标签
receiveHtml(content) { console.log('recieved HTML content', content); this.setState({responseList:[]}); }
onChange = (file, fileList, event) => { console.log('onChange', file, fileList, event);
}
beforeUpload = (file) => { const reader = new FileReader(); reader.readAsDataURL(file); reader.onloadend = function () { const options = { method: 'POST', body: { file: reader.result, }, } request('url', options) .then(result => { console.log('test'); this.setState({ responseList: [{ uid: '-1', status: 'done', url: result.file, }], }); }) .catch(error => { console.log(error); }) }.bind(this); return false; }
render() { const uploadProps = { action: 'url', onChange: this.onChange, listType: 'picture', fileList: this.state.responseList, multiple: true, beforeUpload: this.beforeUpload, showUploadList: true, } return (
代码中实际url地址已经替换为url字符串
插入音频也是类似情况
received后fileList的列表要置空,否则下次上传还会将之前的列表上传一遍的。