html
vue
1. cnpm i fastclick --save
2. 在main.js中引入並綁定到body
import fastclick from 'fastclick';
3. fastclick.attach(document.body);
react
1. Install
npm
install
--save-dev react-fastclick-alt
2. 用法
將元素或者component放在 <FastClick>...</FastClick> 中
3. 監測到tap事件后會阻止冒泡 event.stopPropagation()
import
React from
'react'
;
import
React from
'react'
;
import
FastClick from
'react-fastclick-alt'
;
import
ReactDOM from
'react-dom'
;
ReactDOM.render(<FastClick><MyApp/></FastClick>, document.getElementById(
'app'
));
4. 兩個參數
threshold 在px中不能再轉換為點擊之前,觸摸可以移動多遠。 默認為15px。
timeThreshold 在不能再將點擊轉換為點擊之前可以持續點擊多長時間,以毫秒為單位。 默認為125毫秒。