将Dropzone与Typescript一起使用 [英] Using Dropzone with Typescript

查看:117
本文介绍了将Dropzone与Typescript一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用dropzone 4.3并用Typescript编写的应用程序。在将其转换为打字稿之前,我们必须在Dropzone上设置一个全局变量,一切都很顺利。

I have an app that uses dropzone 4.3 and is written in Typescript. Prior to converting it to typescript, we had to set a global variable on Dropzone and everything was happy.

Dropzone.autoDiscover = false;

我已经加入了以下节点包:

I've pulled in these node packages:

    "@types/dropzone": "^4.3.35",
    "dropzone": "4.3.0",

现在,自动发现行给我这个错误:

Now, the autodiscover line gives me this error:

Error   TS2686  'Dropzone' refers to a UMD global, but the current file is a module. Consider adding an import instead.

为了解决该问题,我添加了以下内容:

In order to solve that problem, I added this:

import * as Dropzone from 'dropzone';

现在,我留下了这个错误:

Now, I'm left with this error:

Error   TS2540  Cannot assign to 'autoDiscover' because it is a constant or a read-only property.   

我哪里出错了?

推荐答案

您可以将autoDiscover设置为false,如下所示:

You can set autoDiscover to false as follows

import * as Dropzone from "dropzone";    
const dz = Dropzone
dz.autoDiscover = false;

我从此链接 https://github.com/zefoy/ngx-dropzone-wrapper/blob/fb3fc3cc3ec /lib/dropzone.directive.ts#L60

这篇关于将Dropzone与Typescript一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆