我似乎面临prototypejs和jquery之间的冲突。下面是一个代码示例来说明(我知道它不是很好,我只是为了调试目的而创建它):
<html> <head>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<script type="text/javascript" src="/CR0000086/js/jquery.js"></script>
<!-- bug here if I add this line : <script type="text/javascript" src="/CR0000086/js/prototype.js"></script> -->
<link rel="stylesheet" href="/CR0000086/css/bootstrap-datepicker.min.css">
<script type="text/javascript" src="/CR0000086/js/bootstrap-datepicker.min.js"></script>
</head> <body>
<!-- test1 with datepicker -->
<input type="text" id="example1" class="hasDatePicker"> <script>
$("#example1").datepicker(); </script>
<!-- test2 with pickadate-->
<div class="form-group"> <div class="input-group">
<input type="text" class="date-input form-control"/>
<span class="input-group-btn">
<button class="date-button btn btn-default" type="button"> @ </button>
</span> </div> <div id="date-picker"> </div> </div>
<link rel="stylesheet" href="/CR0000086/css/pickadate.css">
<script type="text/javascript" src="/CR0000086/js/pickadate.js"></script>
</body> </html>
该页面运行良好,我看到了我的两个日期选择器,但是,如果我取消注释该行以加载prototype.js,我会收到以下错误:
Cannot read property 'datepicker' of null
Cannot read property 'pickadate' of null
如果你想重现那个bug,这里是我用过的软件包的链接:
我尝试了很多解决方案,包括JQuery.noConflict(),我想解决方案必须处理这个错误:http://www.softec.lu/site/DevelopersCorner/BootstrapPrototypeConflict
但我必须承认,对我来说,javascript的级别太高了,我需要帮助才能使这些日期选择器中的一个加载 prototypeJS。
你可以帮帮我吗?或者,如果您有其他解决方案(我需要一个日期选择器),任何想法都将不胜感激致以最诚挚的问候,
于连