Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor Checkbox components #463

Open
24 tasks done
qiqingfu opened this issue Dec 11, 2020 · 0 comments
Open
24 tasks done

refactor Checkbox components #463

qiqingfu opened this issue Dec 11, 2020 · 0 comments
Labels
refactor Refactor old code

Comments

@qiqingfu
Copy link
Contributor

qiqingfu commented Dec 11, 2020

Tasking

  • 设置显示内容

    • 使用 slot 设置默认内容
    • 当未设置 label 和 slot 时,不显示任何内容
  • label 属性

    • 不存在 slot 且 label 存在,label 作为默认内容
    • slot 和 label 同时存在时,slot 优先级比 label 高
  • 双向绑定

    • 单个 checkbox 使用 v-model 双向绑定
  • border

    • 通过 props.border 设置是否显示边框
    • 当未设置 props.border 时,从 elCheckboxGroup.border 组件获取
  • size

    • 仅当 props.border 设置时,props.size 尺寸才生效
    • 当未设置 props.size 时,依次从 elCheckboxGroup.size、elForm.size、$ELEMENT.size 获取
  • disabled

    • 通过 props.disabled 设置禁用状态
    • 当未设置 props.disabled 时,依次从 elCheckboxGroup.disabled、elForm.disabled 获取
  • name

    • 通过 props.name 为 设置原生 name 属性
  • trueLabel、falseLabel

    • 当设置 props.trueLabel,选中返回 trueLabel 值
    • 当设置 props.falseLabel,选中返回 falseLabel 值
  • 设置当前选中

    • 设置 props.checked 为 true 时,会触发 upload:modelValue 事件,数据是 trueLabel 值
  • indeterminate

    • 通过 props.indeterminate 设置半选中状态
  • 聚焦与失去焦点

    • checkbox 聚焦时样式
    • checkbox 失焦时样式
  • change

    • 当 checkbox 选中状态发生变化,触发 change 自定义事件
  • 多选框组

    • 双向绑定

      • 初始时, checkbox label 属性包括在 checkboxGroup 的 modelValue 中,应为选中,否则为不选中
      • checkbox 点击,当 label 不存在 checkboxGroup.modelValue 时,应选中
      • checkbox 点击,当 label 存在 checkboxGroup.modelValue 时,应取消选中
    • 事件

      • 当 checkbox 改变,应通知 checkboxGroup
      • checkbox 选中或取消选中最新结果,同步给 checkboxGroup
      • props.modelValue -> checkbox-group -> checkbox -> change newModelValue -> checkbox-group -> emit('update:modelValue')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Refactor old code
Projects
None yet
Development

No branches or pull requests

2 participants