默认日期值未显示在模式中

Default date value not showing in a Modal

我有完全相同的代码:

<input type="date" class="form-control" name="date" id="date" value="2021-04-16">

在主页和模式中,参数 value="2021-04-16" 在主页中有效,但在模式中无效。

我在这里错过了什么?

[https://codepen.io/Bodock/pen/oNBMbdP?editors=1010][1]

只需更改(删除动画淡入淡出)

<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">

<div class="modal" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">

删除模态的背景,这样动画也能正常工作...

 var exampleModal = document.getElementById('exampleModal')
  exampleModal.addEventListener('show.bs.modal', function (event) {
  exampleModal.querySelector('.modal-backdrop').remove(); // SEE THIS LINE
  var button = event.relatedTarget
  var recipient = button.getAttribute('data-bs-whatever')
  var modalTitle = exampleModal.querySelector('.modal-title')
  var modalBodyInput = exampleModal.querySelector('.modal-body input')
    modalTitle.textContent = 'Why: ' + recipient
    modalBodyInput.value = recipient
 })