webpack 引入 fastclick报错?

问题:根据文档引入fastclick报错。

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

报错信息

阅读 3.6k
4 个回答
import FastClick from 'fastclick'
!window.detachFastclick && FastClick.attach(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);

是不是你这个trackingClick事件没有在methods里声明啊

如果在打包工具中,应该CMD模块模式写法:

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

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

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

如果有帮助,请采纳

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题