search

Home  >  Q&A  >  body text

javascript - What are the differences between the two instantiation methods of Vue?

new Vue({
    router,
    store,
}).$mount('#app')

new Vue({
  el: '#app',
  store,
  router,
  template: '<App/>',
  components: { App }
})

What is the difference between these two ways of instantiating Vue?
What is the relationship between the three files main.js, App.vue, and index.html in the project structure?

滿天的星座滿天的星座2757 days ago769

reply all(1)I'll reply

  • 欧阳克

    欧阳克2017-06-12 09:33:01

    First of all, there is no essential difference between these two writing methods, and there is no problem as the entrance to the entire project.

    Specifically speaking of the project structure, main.js is the entrance to the entire project (in addition to importing the UI of App.vue, auxiliary libraries and plug-ins such as router/vuex/axios are also imported). App.vue is the entrance to the UI logic. Index.html introduces main.js through the script tag and injects the content of the script execution into #app.

    reply
    0
  • Cancelreply