SortableJS / Vue.Draggable

Vue drag-and-drop component based on Sortable.js
https://sortablejs.github.io/Vue.Draggable/
MIT License
20.03k stars 2.89k forks source link

TypeError: Sortable is not a constructor #734

Closed sgrossberndt closed 4 years ago

sgrossberndt commented 4 years ago

The commit 7d4db6f324c54ba13af6c80390fca6e6a943d21c breaks vue-draggable for client usage. Generated code from this in vuedraggable.umd.js is var Sortable = __webpack_require__("a352").default; which leads to [Vue warn]: Error in mounted hook: "TypeError: Sortable is not a constructor" (or [Vue warn]: Error in mounted hook: "TypeError: u is not a constructor" when using vuedraggable.umd.min.js).

The problem seems to be that default is not defined - __webpack_require__("a352") already contains the Sortable object. Thus changing the line to var Sortable = __webpack_require__("a352"); fixes the issue.

smfinvest commented 4 years ago

I am also seeing this message when I run locally with Webpack. It seems that the webpack loads different js modules then the IIS machine. I am using 2.16

David-Desmaisons commented 4 years ago

Corrected in version 2.23.2

KevinMMontalvo commented 1 year ago

For me I solved ordering the dependencies in typical use

<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.8.4/Sortable.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Vue.Draggable/2.20.0/vuedraggable.umd.min.js"></script>

Sortable first, and vuedraggable second