从导入的文件定义 Class

define Class from imported file

我正在尝试使用 fengyuanche 的 "cropperjs",ESLint 报告未定义 Class。什么是正确的申报方式?谢谢。

这是我正在尝试做的事情的片段:

define( ["./cropperjs/dist/cropper"], () => { 

    function initCropper($options) {

            // ESlint : "Cropper" is undefined
            const cropper = new Cropper (...)
            return cropper;
    }
    (...)
}

您需要将其添加到define回调中:

define( ["./cropperjs/dist/cropper"], (Cropper) => { 

    function initCropper($options) {

            // ESlint : "Cropper" is undefined
            const cropper = new Cropper (...)
            return cropper;
    }
    (...)
}