英文:
Updating Vue 2 to Vue 3
问题
我有一个旧的Vue 2项目,我们正在迁移到Vue 3,它使用了Bootstrap,考虑到它的旧版本与Vue 3不兼容,所以我最终移除了它。除了这个错误之外,一切似乎都正常,错误信息如下:
未找到此依赖项:
* vue 在 ./src/main.js、./src/api/store.js 和其他 3 处
要安装它,可以运行:npm install --save vue
我使用了vue update
来更新到Vue 3,使用npm update
升级了一些依赖项,并且第一次在npm命令中使用了--legacy-peer-deps
,之后删除了main.js
中的Bootstrap导入后,一些错误已被解决。我搜索了一下,但似乎找不到解决方案,因为我在Vue 3上的经验有限,所以非常感谢任何帮助。
/编辑/
我将import Vue
更改为vue createApp
,在终端中出现了一些错误,终端告诉我需要更新vue-loader
到最新版本,我照做了,但现在出现了这个错误。
为了确保至少能够加载app.vue
,我已经删除了几乎所有的Vue.use
项,然后可以从那里继续。我正在遵循这个教程:链接到教程
即使在Webpack配置文件中有VueLoaderPlugin
,我仍然遇到了这个问题:
const VueLoaderPlugin = require('vue-loader/lib/plugin')
英文:
I have an old Vue 2 project that we are migrating to Vue 3, it had bootstrap which I ended up removing considering its old versions don't work really well with vue 3. Everything else seems fine except this error,
This dependency was not found:
* vue in ./src/main.js, ./src/api/store.js and 3 others
To install it, you can run: npm install --save vue
I used vue update to update to vue 3, npm update to upgrade some dependencies, and had to use --legacy-peer-deps with the npm commads the first time, I had some errors which were removed after removing bootstrap imports from main.js. I have looked around, can't seem to find the solution for this, haven't worked with Vue3 a lot, any help would be appreciated thanks.
<br />
This is my main.js
This is me initializing app --- used to work before vue update
/Edit/
I changed import Vue to vue createApp, had some errors in terminal and terminal told me to update vue-loader to latest version, which I did and now I'm getting this error.
I have removed almost all of Vue.use items to make sure atleast app.vue loads and then I can move on from there. I'm following this tutorial
https://blog.logrocket.com/refactoring-vue-2-apps-vue-3/
I'm getthing this issue even though VueLoaderPlugin is in webpack config file
<br />
const VueLoaderPlugin = require('vue-loader/lib/plugin')
答案1
得分: 1
这只是Vue 3中不再像以前那样工作。import Vue
和new Vue()
已被替换为:
import { createApp } from 'vue';
const app = createApp(App);
Vue 3不是Vue 2的直接替代品;你可能需要阅读一些重大变更。
英文:
It simply doesn't work like that anymore in Vue 3. import Vue
and new Vue()
have been replaced by:
import { createApp } from 'vue';
const app = createApp(App);
Vue 3 isn't a drop-in replacement for Vue 2; there's a number of breaking changes you should probably read up on.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论