vue组件试错

[Vue warn]: Property or method "child1" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.

解:在使用动态组件<component :is="prop_from_data">的时候,prop_from_data没有指向vue实例中data的某个属性,该属性指向某个组件。

结论:大家一定要保养好眼睛。

另外在组件嵌套时要注意,2.+版本后子组件的模板只能有一个根元素,也就是

<div>

<child1>

<child2>

</div>

而不是

<child1>

<child2>

而且不要用v-for渲染根元素。

posted @ 2017-08-06 17:55  瓶子2333  阅读(192)  评论(0编辑  收藏  举报