Console warnings for non-passive scroll event handlers

北城余情 提交于 2019-12-11 02:36:10

问题


I'm getting this console error when I use Form Select from bootstrap-vue. I'm using google chrome.

[Violation] Added non-passive event listener to a scroll-blocking 'mousewheel' event. Consider marking event handler as 'passive' to make the page more responsive.

I'm getting this data from a api, using axios. See the code below.

<b-form-select v-model="selected" class="mb-3">
    <option :value="null">Select a group</option>
    <option v-for="group in groupItem" :value="group.id">
        {{group.name}}
    </option>
</b-form-select>

回答1:


It's related to the new event listener options, more here and here

There is a new options object that can be passed to the addEventListener. The passive event listeners on the page should be passed the { passive: true } option to improve scroll performance.

document.addEventListener('touchstart', handler, { passive: true });

The warning is only a performance recommendation, not really a major concern or issue, although performance improvements are always good.

An issue has already been reported at the bootstrap-vue repository. You can fix it by either submitting a pull request, or waiting for someone else to do it.



来源:https://stackoverflow.com/questions/53069871/console-warnings-for-non-passive-scroll-event-handlers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!