jQuery select2 打开后立即自动关闭

Js *_*Lim 4 jquery-select2

select2 位于 bootstrap 4 模态中,并且仅发生在模态中。

选择2错误

请参阅上面的屏幕截图,当我单击该元素时,它会显示,然后关闭。

在 Chrome 控制台中,我看到这些警告

[Violation] Avoid using document.write().
[Violation] Forced reflow while executing JavaScript took 33ms
[Violation] 'readystatechange' handler took 151ms
Run Code Online (Sandbox Code Playgroud)

这是我的代码

[Violation] Avoid using document.write().
[Violation] Forced reflow while executing JavaScript took 33ms
[Violation] 'readystatechange' handler took 151ms
Run Code Online (Sandbox Code Playgroud)
  • 操作系统:macOS Mojave
  • Chrome:73.0.3683.103(64位)
  • 引导程序:v4.1.3
  • select2:v4.0.5 (带有select2-bootstrap-theme/0.1.0-beta.10)

P/S:这并不总是发生

Js *_*Lim 7

我想我已经在这里找到了解决方案,我错过的是.modal-content

dropdownParent: $('#bootstrap4-modal .modal-content'),
Run Code Online (Sandbox Code Playgroud)

现在 select2 正确显示