简体   繁体   English

在使用 React Native 构建的移动应用程序中包含外部 javascript 文件

[英]Include external javascript file in mobile app built using react native

I'm trying to add cloudinary upload widget to my mobile app built using react native.我正在尝试将 cloudinary 上传小部件添加到我使用 React Native 构建的移动应用程序中。

The documentation for integrating this widget in app says 'Include javascript file in your webpage.'在应用程序中集成此小部件的文档说“在您的网页中包含 javascript 文件”。

Is it possible to include this javascript file in react native for a mobile application?是否可以在移动应用程序的 react native 中包含此 javascript 文件?

Whatever I could find online talks about including this file in WebView of react native but that would mean a web application for a mobile right?无论我能在网上找到关于在 React Native 的 WebView 中包含这个文件的讨论,但这意味着移动网络应用程序对吗? I'm trying to build a mobile application and include this external javascript file in it.我正在尝试构建一个移动应用程序并在其中包含这个外部 javascript 文件。

Is it possible to do so?有可能这样做吗? And if so, how would we go about it?如果是这样,我们将如何处理?

You can use:您可以使用:

class Widget extends React.Component {
    uploadWidget = () => {      
        cloudinary.openUploadWidget({ cloud_name: "<cloud_name>", upload_preset: "<upload_preset>", sources:['local','url','facebook','dropbox', 'google_photos'], folder: "test"}, 
            function(error, result){ 
                console.log(error);
        });         
    }
  render() {
    return(
    <div>
      <div>Please update your cloudname and upload preset</div>
      <input type="button" value="click me" onClick={this.uploadWidget}/>
    </div>
    );
  }
}

ReactDOM.render(
  <Widget/>,
  document.getElementById('container')
);

http://jsfiddle.net/RayStra/gevc4ktm/ http://jsfiddle.net/RayStra/gevc4ktm/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM