鍍金池/ 問答/網(wǎng)絡(luò)安全  HTML/ webpack 引入 fastclick報錯?

webpack 引入 fastclick報錯?

問題:根據(jù)文檔引入fastclick報錯。

 var attachFastClick = require('fastclick');
     attachFastClick(document.body);

報錯信息

回答
編輯回答
吢丕

https://github.com/ftlabs/fas...

If you're using Browserify or another CommonJS-style module system, the FastClick.attach function will be returned when you call require('fastclick'). As a result, the easiest way to use FastClick with these loaders is as follows:

var attachFastClick = require('fastclick');
attachFastClick(document.body);

2017年10月1日 19:31
編輯回答
傻叼

如果在打包工具中,應(yīng)該CMD模塊模式寫法:

var attachFastClick = require('fastclick');
attachFastClick(document.body);

如果事script引用 ,使用AMD 模式的寫法:

var FastClick = require('fastclick');
FastClick.attach(document.body, options);

如果有幫助,請采納

2017年1月20日 09:25
編輯回答
貓館

是不是你這個trackingClick事件沒有在methods里聲明啊

2018年7月3日 19:40
編輯回答
逗婦乳
import FastClick from 'fastclick'
!window.detachFastclick && FastClick.attach(document.body)
2017年11月5日 09:08