Uncaught TypeError: event.preventDefault is not a function at handleKeyPress

Uncaught TypeError: event.preventDefault is not a function at handleKeyPress

问:

Uncaught TypeError: event.preventDefault is not a function at handleKeyPress (index.html:1247:23) at HTMLLIElement.<anonymous> (index.html:1475:31)

回答:

因为当click的时候没有event.preventDefault,

点击事件对象 event 并不具有 preventDefault 方法所以报错,

我们增加了一个判断: 当回车keyCode === 13的时候才使用event.preventDefault, 否则不使用.

转载请说明出处内容投诉
CSS教程网 » Uncaught TypeError: event.preventDefault is not a function at handleKeyPress

发表评论

欢迎 访客 发表评论

一个令你着迷的主题!

查看演示 官网购买