在创建自己组件的时候,template中直接使用v-for指令无法渲染,以下是错误代码:Vue.component('component-test',{
    props: {
      testData: {
        type: Array,
        default: []
      }
    },
    template: '<li v-for="(item,index) in testData">{{item}}</li>' //这里直接使用v-for指令,后页面无法渲染出元素。
})使用watch发现testData已经传到子组件了,然而页面对应的元素没有渲染出来,此时,如果给li前面加上ul的话就可以渲染的出来,下面为正确代码:Vue.component('component-test',{
    props: {
      testData: {
        type: Array,
        default: []
      }
    },
    template: '<ul><li v-for="(item,index) in testData">{{item}}</li></ul>' //在v-for对应的元素前面加一个父元素
  })此时问题是解决了,但是这其中的原理是怎样的呢?为什么直接在template使用v-for指令无法渲染呢?哪位大神能够解答一下,感谢!!!