vue 报错: Cannot use v-for on stateful component root element because it renders multiple elements.

原因:
不能直接在组件的根元素直接使用v-for,外面必须嵌套一层容器.
解决代码如下:

 Vue.component('my-menu',
            {
                props: ['nickname', 'age'],
                template: 
                `
{{nickname}}--{{age+10}
`
, data() { return { list: ['ss', 'qq', 'ww'] } }, methods: { zz() { alert('lw') } } } )

你可能感兴趣的:(vue 报错: Cannot use v-for on stateful component root element because it renders multiple elements.)