提问者:小点点

无法将cropper.js模块包含到我的代码中


为了给我的一个flask/jinja页面添加图像裁剪支持,我遵循了GitHub上的cropper.js使用示例,将CSS链接添加到我的HTML页面的中,并将以下内容添加到我的页面的中:

<script src="/static/assets/js/plugins/cropper.min.js" type="module"></script>
<script>
    import Cropper from "cropperjs";

    const image = document.getElementById('crop_image');
    const cropper = new Cropper(image, {
        aspectRatio: 1 / 1,
        crop(event) {
            console.log(event.detail.x);
            console.log(event.detail.y);
            console.log(event.detail.width);
            console.log(event.detail.height);
            console.log(event.detail.rotate);
            console.log(event.detail.scaleX);
            console.log(event.detail.scaleY);
        },
    });
</script>

可以找到cropper.min.js文件,正如我在Firefox 77.0.1浏览器控制台中看到的。
但是,我确实在控制台中得到以下错误消息:

SyntaxError: import declarations may only appear at top level of a module

在JS