[英]How to use Dropbox-sdk-js in the browser?
I have been trying to get the dropbox-sdk-js running in the browser. 我一直试图在浏览器中运行dropbox-sdk-js 。 The sdk is developped for node. 为节点开发了sdk。
What I need is to include the sdk in a <script>
tag and start using the SDK in JS. 我需要将sdk包含在<script>
标记中并开始在JS中使用SDK。
I tried Webpack and Browserify. 我尝试了Webpack和Browserify。 But none of them seem to unentangle the Dropbox
js object from require
for me to use in the browser. 但是它们似乎都没有使Dropbox
js对象脱离require
让我在浏览器中使用。 Simply requre
is undefined both after webpack and browsify. 在webpack和浏览后,简单的requre
都未定义。
-- Reproduce -- -复制-
Go to the root folder of the repo and execute webpack
. 转到webpack
的根文件夹并执行webpack
。 This will read webpack.config.js
and create dropbox-sdk.js
in dist
folder 这将读取webpack.config.js
并在dist
文件夹中创建dropbox-sdk.js
Include the file in my script <script src="dropbox-sdk.js"></script>
在我的脚本<script src="dropbox-sdk.js"></script>
包含文件
Undefined error come when I try to execute var Dropbox = require('dropbox');
当我尝试执行var Dropbox = require('dropbox');
时,出现不确定的错误var Dropbox = require('dropbox');
The script is guaranteed to be included correctly. 保证脚本正确包含。 Even tried to use a precompiled one from this CDN. 甚至尝试使用此 CDN中的预编译版本。
Any help is appreciated. 任何帮助表示赞赏。
If you want to use the dropbox-sdk in browser you either have to use 如果要在浏览器中使用dropbox-sdk,则必须使用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.