最近在项目中发现个奇怪的坑,Simditor 富文本编辑器报错了,错误大致如下:
Uncaught TypeError: Simditor.connect is not a function
at write.js?id=0b2be0e07122e6cd848f:76115
at write.js?id=0b2be0e07122e6cd848f:76341
at Object.<anonymous> (write.js?id=0b2be0e07122e6cd848f:73652)
at write.js?id=0b2be0e07122e6cd848f:73653
at Object../resources/assets/js/plugins/simditor.js (write.js?id=0b2be0e07122e6cd848f:73663)
at __webpack_require__ (write.js?id=0b2be0e07122e6cd848f:20)
at Object../node_modules/babel-loader/lib/index.js?{"cacheDirectory":true,"presets":[["env",{"modules":false,"targets":{"browsers":["> 2%"],"uglify":true}}]],"plugins":["transform-object-rest-spread",["transform-runtime",{"polyfill":false,"helpers":false}]]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./resources/assets/js/components/Editor.vue (write.js?id=0b2be0e07122e6cd848f:1610)
at __webpack_require__ (write.js?id=0b2be0e07122e6cd848f:20)
at Object../resources/assets/js/components/Editor.vue (write.js?id=0b2be0e07122e6cd848f:72884)
at __webpack_require__ (write.js?id=0b2be0e07122e6cd848f:20)
初步判定应该是 jquery 依赖出错,我本地的 jquery 版本为3.1.1;
使用 npm install simditor 安装到最新的 simditor,依赖的 jquery 版本为3.3.1
因此报了 Simditor.connect is not a function 这个错误,由于我的 jquery 版本要固定,所以我把 simditor 降级了,最后安装的版本是 2.3.6 ,可以满足项目的使用