vue组件报错Component template should contain exactly one root element. If you are using v-if on multi...

Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.

这意思是组件使用是需要一个根标签,我们注册父子组件的时候外面要有个div包含父组件和子组件的值

const com = Vue.extend({

    template: `

    

     // 这里要加一个div包括父组件和子组件才可以,要不然会报错

      

你好
 

      

    

`,

    components: {

      con111: com2

    }

  })

你可能感兴趣的:(vue组件报错Component template should contain exactly one root element. If you are using v-if on multi...)