gpt4 book ai didi

javascript - Platform.js (Polymer)、jQuery 2.x.x 和 Bootstrap - 错误

转载 作者:行者123 更新时间:2023-11-29 17:05:28 26 4
gpt4 key购买 nike

在我将 Platform.js (v0.3.4) (Polymer)、jQuery (v2.x.x) 和 Bootstrap.js (v3.2.0) 添加到空白页面后出现奇怪的错误。

对于 Safari 和 Firefox,在(空白)页面上的某些事件(例如单击或键盘输入)会引发错误:

TypeError: 'undefined' is not a function (evaluating 'elem.getAttribute( name )')

jQuery v1.11.1没有问题,其他版本的Platform我没试过。无论是 Chrome 还是 Opera。

如果我在 Bootstrap 中将所有“点击”替换为“dblclick”,则点击时不会再出现错误(当然会发生在 dblclick 上)。

嗯,这没什么大不了的,但令人惊讶。

下面是测试代码:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>PJB</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/polymer/0.3.4/platform.js"></script>
</head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.js"></script>
</body>
</html>

如果有人知道如何在不破坏平台的 Bootstrap、jQuery 的情况下避免此错误,我将很高兴知道。

谢谢。

最佳答案

我认为问题与以下问题有关:https://github.com/Polymer/platform/issues/69

修复似乎是包装文档和/或 document.body。例如:

(function(document) {
// add your jquery handlers here...
$(document).on('click', ...);
})(wrap(document));

更多解释在这里:http://www.polymer-project.org/platform/shadow-dom.html#wrappers

关于javascript - Platform.js (Polymer)、jQuery 2.x.x 和 Bootstrap - 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24942308/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com