Skip to content

Latest commit

 

History

History
19 lines (13 loc) · 452 Bytes

supportsTouchEvents.md

File metadata and controls

19 lines (13 loc) · 452 Bytes
标题 标签
supportsTouchEvents(判断是否支持触摸事件) browser(浏览器)

检查是否支持触摸事件。

  • 检查窗口中是否存在“ontouchstart”。
const supportsTouchEvents = () => window && 'ontouchstart' in window;

调用方式:

supportsTouchEvents(); // true

应用场景