【发布时间】:2021-02-05 10:06:47
【问题描述】:
我在 Django 模板中使用 Bootstrap v4.5.0(不确定是否相关)。具体来说,我正在使用 Bootsrap 表单组件(根据 https://getbootstrap.com/docs/4.5/components/forms/)来显示我的表单元素。
虽然我可以使用表单来选择文件并正常上传,但表单永远不会更新以显示文件已被选中。这是一个问题,因为我有用户认为我的 Web 应用程序没有理由不接受他们的文件。
我包含了所有需要的 JavaScript,并且我已经在不同的浏览器中进行了测试,所以我不确定问题出在哪里。在这个阶段,我不希望使用不同版本的 Bootstap,而且无论如何也不认为这是版本的问题。
我附上了一个演示该问题的 sn-p:
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
</head>
<body>
<div class="custom-file">
<input class="custom-file-input" id="customFile1" name="testfile" type="file" /><label class="custom-file-label" for="customFile1">Upload a file</label>
</div>
</body>
</html>
如果我遗漏了一些明显的东西,我将不胜感激任何指示或指出,谢谢。
【问题讨论】:
标签: html twitter-bootstrap bootstrap-4