search

Home  >  Q&A  >  body text

javascript - vuejs的extend方法在vue2中不知道是否还有,解释一下

ringa_leeringa_lee2767 days ago495

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 16:33:49

    Migrate from Vue 1.x to 2.x
    Migrate from Vue Router 0.7.x to 2.x
    Migrate from Vuex 0.6.x to 1.0(2.0)

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 16:33:49

    Not much change in writing style.
    We provide you with two writing methods, you can use them according to your situation

    
    const router = new VueRouter({ .... })
    
    ...
    // 第一种写法
    const app = new Vue({
        router,
        ...App // 扩展
    }).$mount('#app')
    
    // 第二种
    new Vue({
      el: '#app',
      router,
      template: '<App/>',
      components: { App }
    })

    In additionVue.extend is to use the basic Vue constructor to create a "subclass". The parameter is an object containing the component's options.
    Look at the source code and it will be clear at a glance. global-api/extend

    reply
    0
  • Cancelreply