Checkbox 多选框

基本组件-多选框。主要用于一组可选项多项选择,或者单独用于标记切换某种状态。

代码示例

>{}
<template>
  <Checkbox value="all" @onEvent="onCheckEvent" /> 全选
  <Checkbox
    v-for="(item, index) in the.typeList"
    :named="'check_' + index"
    :key="index"
    v-model="the.typeCk"
    :value="index"
  >
    {{ item }};
  </Checkbox>
</template>

<script>
export default {
  setup() {
    // 使用外挂方式引入,具体查看demo
    const $plus = window.$plus;
    const reactive = $plus.vue.reactive;

    const the = reactive({
      typeCk: [3],
      typeList: ['初始', '正常', '已审', '撤审', '删除'],
    });

    const onCheckEvent = (resp) => {
      console.log('onCheckEvent:', resp);

      //{ cmd: "check", named: "check_2", id: "check_2_WqrvhfyD", value: 2, checked: true }
      // { cmd: "check", named: "check_0", id: "check_0_UKEueUBf", value: 0, checked: false }
      //resp.value 是组件自定义绑定值,根据实际应用定义
    };

    return { the, onCheckEvent };
  },
};
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

Checkbox props

属性说明类型默认值
named 0.4.3组件命名Stringcheck
value只在单独使用时有效Booleanfalse
v-model双向绑定数据String-

Checkbox events

事件名说明返回值
onEvent点击触发回调事件json
cmd 0.4.3checkjson

Checkbox cmd check

参数名说明类型
named组件名String
id控件的随机名称String
value绑定的值String
checked是否选中Boolean

Last Updated: