我创建了一个混合应用程序,其中我使用了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视图中触摸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)
我搜索了很多,但无法找出错误发生的原因,请帮忙。
答案 0 :(得分:7)
这是一个有效的解决方法。使用以下代码片段:
var chromePointerEvents = typeof PointerEvent === 'function'; if (chromePointerEvents) { if (orig.pointerId === undefined) { return; } }
插入后:
touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig];
文件jquery.bxslider.js的
答案 1 :(得分:1)
为什么不试试这个当前版本?
<script src="https://cdnjs.cloudflare.com/ajax/libs/bxslider/4.2.15/jquery.bxslider.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bxslider/4.2.15/jquery.bxslider.min.css" rel="stylesheet" />