Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Twitter bootstrap 引导模式不适用于版本4.4.1_Twitter Bootstrap_Modal Dialog - Fatal编程技术网

Twitter bootstrap 引导模式不适用于版本4.4.1

Twitter bootstrap 引导模式不适用于版本4.4.1,twitter-bootstrap,modal-dialog,Twitter Bootstrap,Modal Dialog,我有一个正常的模态对话框。它使用的是引导版本4.1.0。 现在我升级到4.4.1版,它不再工作了。为什么呢? 我认为这两个版本在模态对话方面没有区别 <div class="modal fade" id="1" tabindex="-1" role="dialog" aria-labelledby="modalLabel_1" aria-hidden="true"> <div class="modal-dialog" role="document">

我有一个正常的模态对话框。它使用的是引导版本4.1.0。 现在我升级到4.4.1版,它不再工作了。为什么呢? 我认为这两个版本在模态对话方面没有区别

<div class="modal fade" id="1" tabindex="-1" role="dialog" aria-labelledby="modalLabel_1" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form action="update" method="POST">
                <div class="modal-header">
                    <h5 class="modal-title" id="modalLabel_1">Edit</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                </div>
                <div class="modal-body">
                    Test

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Schließen</button>
                    <button type="submit" class="btn btn-primary">Speichern</button>
                </div>
            </form>
        </div>
    </div>
</div>

<button type="button" class="btn btn-primary float-right" data-toggle="modal" data-target="#1">
    Open Modal
</button>

这与您的模态
id
是数字有关。如果您将模式的
id
更改为
\u 1
,并将按钮的
数据目标更改为
\u 1
,则会删除它


进一步研究这个问题,在你的例子中

document.getElementById('1')
。。。返回模态,但是

document.querySelector('#1')
。。。返回一个错误:

Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '#1' is not a valid selector.
我的猜测是,在内部,引导使用
querySelector
传递按钮的
数据目标属性。但是,由于没有显示错误,我猜这一切都发生在
try
/
catch
块中。不过,我可能错了,我只是在猜测


…和,研究这个问题发现,从技术上讲,以数字开头的选择器是有效的,但它们需要进一步处理。也就是说,如果您确实想使用数字ID,则您的
s
数据目标
属性必须是
数据目标=“#\31”
数据目标=“#\000031”

看到了

它甚至不是特定于引导的,而是DOM选择器的工作方式:

\31{颜色:红色;}
.\32{颜色:蓝色;}
红色
蓝色
Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '#1' is not a valid selector.