2
在单元测试的jsdom命令行界面中运行。TouchEvent非法构造函数
const event = new window.TouchEvent('touchstart');
TypeError: Illegal constructor
这是为什么不工作? 根据这个MDN列表它应该通过构造函数工作。
这工作得很好:
const event = new window.MouseEvent('mousemove');
这也适用,但不建议:像你提到
const event = document.creatEvent('touchstart');
这不是事件名称的问题,这是构造函数的问题。 –