SortableJS / vue.draggable.next

Vue 3 compatible drag-and-drop component based on Sortable.js
https://sortablejs.github.io/vue.draggable.next/#/simple
MIT License
3.84k stars 525 forks source link

Introduction and use will cause serious problems: Uncaught ReferenceError: defineComponent is not defined #27

Open hairyf opened 3 years ago

hairyf commented 3 years ago

Version

vue: 3.0.7 vite: 2.0.5 vuedraggable: 4.0.1

image image image

Steps to reproduce

npm run dev

What is expected?

The page is displayed normally

What is actually happening?

Page crash

zhenzhenChange commented 3 years ago

or

upeartaker commented 3 years ago

I also encountered this kind of problem. Could you please tell me how to solve it

upeartaker commented 3 years ago
  • Remove node_modules
  • Reinstall dependency packages

or

  • yarn vite --force

It doesn't solve the problem

zhenzhenChange commented 3 years ago

我想我知道了,怎么会出现这个问题。

因为我只安装 vue 这个包。

但是我导入却不是从 vue 导入的。

比如:

import { defineComponent } from '@vue/runtime-core'

就会报上面的错误。

首先 vite 发现了新的包,然后会去走一遍流程(优化流程吧,我也不是很理解这块),虽然终端没有报错,但是依赖优化的流程已经走一遍了,并且在本地有了缓存,页面上也出现了上面的报错问题。

error

正确的导入应该是从 vue 导入:

import { defineComponent } from 'vue'

并且你还要刷新一下缓存,重新编译:yarn vite --force

英语不好,就不机翻了,见谅。。

zhenzhenChange commented 3 years ago

关于自动导入错误,可能跟以下有关:Volar 插件、VSCode 本身,配置出现了问题,导致自动导入的来源不对劲。