我创建了一个混合应用程序,我在其中使用了 bxslider 并将 div 放入其中,如下所示,
<div class="bxslider">
<div id="chart1" style="text-align:center">
<span id="barChartTitle">Bar Chart</span>
<svg id="chartCanvas" class="margintop40"></svg>
</div>
<div id="chart2" style="text-align:center">
<span id="trendChartTitle">Trend Chart</span>
<svg id="chartCanvas" class="margintop40"></svg>
</div>
</div>
每当我在 html View 中触摸 bxslider 时,我都会收到以下错误,
jquery.bxslider.js:1109 Uncaught DOMException: Failed to execute 'setPointerCapture' on 'Element': InvalidPointerId
at HTMLDivElement.onTouchStart (http://localhost:8100/js/jquery.bxslider.js:1109:34)
at HTMLDivElement.dispatch (http://localhost:8100/js/jquery-3.1.1.min.js:3:10315)
at HTMLDivElement.q.handle (http://localhost:8100/js/jquery-3.1.1.min.js:3:8342)
onTouchStart @ jquery.bxslider.js:1109
dispatch @ jquery-3.1.1.min.js:3
q.handle @ jquery-3.1.1.min.js:3
jquery.bxslider.js:1234 Uncaught DOMException: Failed to execute 'releasePointerCapture' on 'Element': InvalidPointerId
at HTMLDivElement.onTouchEnd (http://localhost:8100/js/jquery.bxslider.js:1234:32)
at HTMLDivElement.dispatch (http://localhost:8100/js/jquery-3.1.1.min.js:3:10315)
at HTMLDivElement.q.handle (http://localhost:8100/js/jquery-3.1.1.min.js:3:8342)
查了很多也没有找到错误的原因,求助
最佳答案
这是一个可行的解决方法。使用这段代码:
var chromePointerEvents = typeof PointerEvent === 'function'; if (chromePointerEvents) { if (orig.pointerId === undefined) { return; } }
在之后插入:
touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig];
文件 jquery.bxslider.js
更多信息在这里 read simplicitytrade answer on Github .
关于javascript - DOMException 无法在 'setPointerCapture' 和 'Element' 上执行 'releasePointerCapture',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41541121/