Recently, I came into contact with vue3. X project, which has many subtle differences with 2.x. I can’t explain the principle, so I will show it in the simplest form
- CDN form introduction create:
2.x:
const app = new Vue({
el:'#app'
})
Copy the code
3.x:
const app = Vue.createApp({
}).mount('#app')
/ / or:
const app = Vue.createAPP({
})
const vm = mount('#app')
Copy the code
- Main.js in @vue/cli
2.x:
import Vue from 'vue'
Vue.use()
Copy the code
3.x:
import {creatApp} from 'vue'
import App from 'App.vue'
createApp(App).use()
/ / or:
const app = createApp(App)
app.use()
Copy the code