苹果记账反思:抽取公共组件
在写代码时一直牢记:我与重复不共戴天
在目前写的两个页面里,抽取了一些公共组件:
Tag
Type
Input
Button
遇到的问题有:
- 需要传的参数不同,
-
- 用props 父传子
- 用slot ,
比如Input组件 在money页的placeholder是“写点备注吧”
在editLabel页的placeholder是“限三个汉字”
做法是用prop 传递 placeholder变量
EdiltLabel <FormItem isNewTag="+" placeholder="限3个汉字或5个英文字母..." @update:tagName="onTagNameChange" ></FormItem> formItem <input :value="value" @input="onValueChange($event.target.value)" type="text" :placeholder="placeholder">
slot:
在labels页,Button是新建标签
在editLabel页,