gpt4 book ai didi

javascript - 部署时 Bootstrap 文件输入不起作用

转载 作者:行者123 更新时间:2023-12-01 04:38:48 24 4
gpt4 key购买 nike

我正在使用 Bootstrap 文件输入包,它可以在本地工作,但在生产中失败。

This is how it looks on vs

After deployment

我读到可能是js文件加载不正确,但还找不到解决方案。

编辑

这是代码:

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" type="text/javascript"></script>

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- canvas-to-blob.min.js is only needed if you wish to resize images before upload.
This must be loaded before fileinput.min.js -->
<script src="/Scripts/plugins/canvas-to-blob.min.js" type="text/javascript"></script>
<!-- sortable.min.js is only needed if you wish to sort / rearrange files in initial preview.
This must be loaded before fileinput.min.js -->
<script src="/Scripts/plugins/sortable.min.js" type="text/javascript"></script>
<!-- purify.min.js is only needed if you wish to purify HTML content in your preview for HTML files.
This must be loaded before fileinput.min.js -->
<script src="/Scripts/plugins/purify.min.js" type="text/javascript"></script>
<!-- the main fileinput plugin file -->
<script src="/Scripts/fileinput.min.js"></script>
<!-- bootstrap.js below is needed if you wish to zoom and view file content
in a larger detailed modal dialog -->
<link href="/Content/bootstrap-fileinput/css/fileinput.min.css" media="all" rel="stylesheet" type="text/css" />
<div class="form-group">
<label for="input-44" class="col-lg-2 control-label">Cargar fotos</label>
<div class="col-lg-10">
<input id="input-44" name="input44[]" type="file" multiple class="file-loading">
<script>
$(document).on('ready', function () {
$("#input-44").fileinput({
uploadUrl: '/file-upload-batch/2',
'showUpload': false,
maxFilePreviewSize: 10240,
fileActionSettings: {
showUpload: false,
indicatorNew: ''
}
});
});
</script>
</div>
</div> </asp:Content>

最佳答案

在阅读并尝试解决此问题一整天后,我决定查看两个场景(开发/生产)的页面源代码并对它们进行比较。

在开发中,这条线 <script src="/Scripts/fileinput.min.js"></script>
是查看该文件代码的链接。部署时,同一行是无效链接,它会抛出 this error我注意到在 ip(192.168.0.145) 和路径/Scripts 之间缺少我的项目名称。

如果我尝试这个<script src="/MyProject/Scripts/fileinput.min.js"></script>我让它在生产中工作,但在开发中失败,因为它的目标是 192.168.0.145/MyProject/MyProject/Scripts/fileinput.min.js 并且该路径也不存在。

解决方案

只需在开头添加两点,如下所示:

<script src="../Scripts/plugins/canvas-to-blob.min.js" type="text/javascript"></script>
<script src="../Scripts/plugins/sortable.min.js" type="text/javascript"></script>
<script src="../Scripts/plugins/purify.min.js" type="text/javascript"></script>
<script src="../Scripts/fileinput.min.js"></script>
<link href="../Content/bootstrap-fileinput/css/fileinput.min.css" media="all" rel="stylesheet" type="text/css" />

希望这对将来的其他人有帮助。

关于javascript - 部署时 Bootstrap 文件输入不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44075371/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com