移動端使用fastclick 解決


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  FastClick from  'react-fastclick-alt' ;
import  ReactDOM from  'react-dom' ;
ReactDOM.render(<FastClick><MyApp/></FastClick>, document.getElementById( 'app' ));

4. 兩個參數  

  threshold    在px中不能再轉換為點擊之前,觸摸可以移動多遠。 默認為15px。

  timeThreshold   在不能再將點擊轉換為點擊之前可以持續點擊多長時間,以毫秒為單位。 默認為125毫秒。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM