0

Why does the VUE UI main.js code generated by CLI/3 differ from the older syntax, what are its parts and how does it work?

sync(store, router) // for vuex-router-sync
new Vue({
  router, 
  store, 
  render: h => h(App)
}).$mount('#app')

Used to be

sync(store, router) // for vuex-router-sync

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

I also read of a third syntax for using the router without the vuex-router-sync using Vue.extend(... rather than new Vue(

Why do I have to add render now, what is the h function replacing, why was that letter chosen, what is the $mount syntax doing and replacing, why was the $mount syntax chosen?

Also, if this is not a separate topic: Does the new syntax actually do what Vue.extend() does, and if not when do I need to use Vue.extend() instead of new Vue()?

4

1 回答 1

0

好的,我的大部分问题似乎都是由 VUE 团队成员在这里回答的:https ://github.com/vuejs-templates/webpack-simple/issues/29

该问题的作者写道,他在 StackOverflow 上因为这个问题被否决了,事实证明,这个问题非常受欢迎和需要。

从答案中,我理解了为什么选择 h 以及它替换了什么,为什么选择了 $mount 以及它替换了什么。

仍然不确定渲染和扩展。但这是一个单独的问题。

于 2020-09-08T13:47:54.457 回答