preface

It’s been almost a year since Vue3 beta was released in the blink of an eye.

I heard that Vue3 is more fragrant to use with Vite, but considering that the speed of vite version is too fast, learning speed can not keep up with the speed of update ah hello!

Therefore, this learning plan is still based on VUe-CLI, and we will start again after the vite version is stabilized and the wheels are more.

The installation

The procedure for installing Vue3 using the Vue CLI is basically the same as that for Vue2. After entering Vue create Project, set Vue version to 3.x, and configure other options according to previous Vue2 configurations.

Note that only Vue CLI 4.5 or later has the option to select the Vue version. You need to check your Vue CLI version before installing.

Of course, in addition to the command line installation, you can also choose to use the visual tool installation, enter the Vue UI, follow the interface prompts foolproof operation is ok.

In addition, the operation after installation is exactly the same as before (such as the configuration of vue.config.js, directory structure, NPM command, etc.).

Create a Vue instance

In Vue2, new Vue() is used to create a Vue instance, whereas in Vue3, the createApp() API is used to create an application instance and then chain-call the other methods.

// main.js
import {createApp} from "vue"
import App from "./App.vue"
import router from "./router"
import store from "./store"

const app = createApp(App)

app.use(router)
    .use(store)
    .mount("#app")
Copy the code

The above content is personal learning arrangement, if there are mistakes welcome to correct ha!