Touch 事件(Event) preventDefault 出錯

Ryan Hsu
Ryan Hsu
Sep 6, 2018 · 4 min read

什麼是 preventDefault?為什麼會出錯?

“white and red first aid case on wall” by rawpixel on Unsplash

緣由

公司產品 QA 回報某個操作情境下會在 console 中有錯誤訊息如下,但不影響功能使用,養成修掉錯誤的好習慣,才不會在未來留下團隊的技術債,讓我們來抽絲剝繭找出為什麼吧 !

追查原始碼後,發現出錯的部分在於 event.preventDefault() ,以下是範例程式碼。

Ryan Hsu

Written by

Ryan Hsu

Front-end developer

Its Ok to Make Mistakes

分享UI UX 設計、前端開發、數位行銷所遇到的雷點 。It’s not how we make mistakes, but how we correct them that defines us.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade