代码之家  ›  专栏  ›  技术社区  ›  theITvideos

SharePoint Framework SPFx的React Dropzone

  •  0
  • theITvideos  · 技术社区  · 7 年前

    有谁能告诉我一个使用React Dropzone npm包的工作代码,该包可用于正在使用React的SharePoint Framework?

    非常感谢。

    0 回复  |  直到 7 年前
        1
  •  0
  •   Petter Dahl    7 年前

    我有一个1.8.2的工作示例

    import Dropzone from 'react-dropzone';
    import * as React from 'react';
    public render(): React.ReactElement<IAccountReaderProps> {
            return <div>
                <Dropzone onDrop={this.onDrop}>
                    {({ getRootProps, getInputProps, isDragActive, isDragAccept, isDragReject, acceptedFiles, rejectedFiles }) => {
    
    
                        return (
                            <div> 
                                 <div {...getRootProps()} className={styles.dragAndDropWrapper}>
    
                                <input {...getInputProps()} />
                                <div>
                                    <h1>Drag and drop file here</h1>
                                </div>
                                {isDragReject && <div>Unsupported file type...</div>}
                            </div>
                            </div>
    
                        );
                    }}
                </Dropzone>
            </div>;
        }
    
    
     private onDrop = (acceptedFiles, rejectedFiles) => {
    
    
    
        }
    
    推荐文章