组件化编码流程
**拆分组件**
实现静态组件:按照功能点拆分。
实现动态组件:有共同的数据,数据放在所有组件的父组件上。
实现交互:绑定事件。
**传数据**:props:[]
子传父:父给子先传一个函数,子调用函数,给一个参数。
父:
<MyHeader :give="give"></MyHeader>
methods: {
give(x) {
this.todos.push(x)
}
}
子:
props: ['give']
this.give(todoObj)
tip:
判断不为空!
if (!this.title.trim() == '')