首页 > 解决方案 > 为什么我在 ASP.Net 中的cropper.js 文件上收到 404 错误,尽管它们正是程序正在寻找它们的位置?

问题描述

在尝试将cropper.js导入到我的ASP.Net 项目中时,我复制并粘贴了为实现它而给出的示例代码。但是,每当加载页面时,我都会收到来自主cropper.js 文件的一系列 404 错误,表示未找到其他 javascript 文件。我确保它们位于 Scripts/cropperjs/src/js 中,这是 404 错误的来源。我需要做什么才能让这些文件被识别?

这是我在页面上的确切代码:

<script type="module">
    import 'cropperjs/dist/cropper.css';
    import Cropper from 'cropper.js';

    const image = document.getElementById('cropperJS');
    const cropper = new Cropper(image, {
        aspectRatio: 16 / 9,
        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>

标签: javascriptasp.netcropperjs

解决方案


您是否已将以下几行添加到您的<head>部分?

<link  href="/path/to/cropper.css" rel="stylesheet">
<script src="/path/to/cropper.js"></script>

推荐阅读