It’s been a while since VUE3 was released, but the author doesn’t really have a hand in it.
Today, try to build a VUE3 based environment locally. Found a lot of pits. Make a note of it so you don’t step on it later.
If you already have vue2 installed locally, uninstall it first and then install vue3
Vue2 NPM uninstall vue-cli -g // Install vue3 NPM install -g@vue /cliCopy the code
Check whether vUE-v is successfully installed after installation
The commands for vue3 have also changed. There are many differences between Vue2 and VUe3, which we will update in a future article to help you get used to vue3 faster.
vue create <name>
Copy the code
And then like VUe2, it lets you choose the dependencies of the installation and things like that, you just watch the installation.
For a deeper understanding, I chose the second one. After installation, open main.js and you’ll find that the configuration is different from the previous one.
Used to be
import Vue from 'vue'
import App from './App.vue
new Vue({
el: '#app',
render: h => h(App)
});
Copy the code
Vuex and VuE-Router should be installed in the project, then follow the previous commands to install.
npm install vuex
npm install vue-router
Copy the code
However, this is an error, so after downloading you find that no matter how you configure it is an error.
Be sure to open package.json and type against the diagram, then re-install.
The specific reason, I guess, is because vue3 is not supported in the old version, which is installed with the previous command.
Now that I have vuex and VuE-Router installed, I want to have a UI framework inside, ready to use Element-UI
Or install the official website command and configuration, found will report an error, here I can not find the error information, I will not give you posted, anyway, is now element does not support VUe3, reporting an error is very normal, the source code is very clear. The official website does say that there are plug-ins for VUE3
vue add element
Copy the code
But believe me, the pro test is invalid, there will be a problem, also looked at the source code, there is still vue2 configuration. I haven’t found a VUe3 compatible UI framework yet. Everyone has a good framework can recommend to me. 🙏 🙏 🙏
Updated 2021.2.25
Find out the correct way to install Element on the Element-Plus website
Element-plus.org/#/zh-CN/com…