React程序

时间:2017-08-02 04:17:18

标签: reactjs google-picker

这是我的GooglePicker

<GooglePicker clientId={'ClientID'}
                         developerKey={'API Key'}
                         scope={['https://www.googleapis.com/auth/drive.readonly']}
                         onChange={this.onChange}
                         multiselect={true}
                         navHidden={true}
                         authImmediate={false}
                         mimeTypes={['image/png', 'image/jpeg', 'image/jpg']}
                         viewId={'DOCS_IMAGES'}>
               <button type="button" id="pick">Pick File</button>  
            </GooglePicker>

这是我的onchange功能

onChange() {
       console.log("Change is logged here");
}

我可以显示选择器按钮并从谷歌驱动器中选择文件。但是没有调用onChange函数。请让我知道代码中的缺陷。

1 个答案:

答案 0 :(得分:1)

尝试发送onChange函数,例如arrow function

<GooglePicker clientId={'ClientID'}
                         developerKey={'API Key'}
                         scope={['https://www.googleapis.com/auth/drive.readonly']}
                         onChange={(data) => this.onChange(data)}
                         multiselect={true}
                         navHidden={true}
                         authImmediate={false}
                         mimeTypes={['image/png', 'image/jpeg', 'image/jpg']}
                         viewId={'DOCS_IMAGES'}>
               <button type="button" id="pick">Pick File</button>  
            </GooglePicker>