Swiper.js 报错: Uncaught TypeError: Cannot read properties of undefined (reading 'onTouchEnd') at Swiper.onTouchEnd 作者: Chuwen 时间: 2021-11-30 分类: JavaScript Uncaught TypeError: Cannot read properties of undefined (reading 'onTouchEnd') at Swiper.onTouchEnd ![Uncaught TypeError: Cannot read properties of undefined (reading 'onTouchEnd') at Swiper.onTouchEnd](https://cdn.nowtime.cc/2021/11/30/1438435762.png) 当我百思不得其解的时候,想到自己改动了 `freeMode` 参数部分,然后导致手动滑动的时候,就报出了这个错误。 原因是因为是按模块导入的,没有导入 `freeMode` 模块,只需要导入并使用即可: ```js import 'swiper/css'; import Swiper, {Autoplay, FreeMode} from 'swiper'; Swiper.use([Autoplay, FreeMode]); ``` 标签: Swiper.js, Swiper, Swiperjs