layui/example/docs/zh-CN/components/checkbox.md

221 lines
3.5 KiB
Markdown
Raw Normal View History

::: anchor
:::
2021-10-26 01:13:23 +08:00
::: title 基础使用
2021-10-24 21:31:42 +08:00
:::
2021-10-12 16:22:26 +08:00
::: demo
<template>
<lay-form>
2021-11-18 00:45:22 +08:00
<lay-checkbox name="like" skin="primary" v-model="checked1" label="1" ></lay-checkbox>
2021-10-12 16:22:26 +08:00
</lay-form>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const checked1 = ref(false)
2021-10-12 16:22:26 +08:00
return {
checked1
2021-10-12 16:22:26 +08:00
}
}
}
</script>
:::
2021-10-26 01:13:23 +08:00
::: title 默认样式
2021-10-24 21:31:42 +08:00
:::
2021-10-13 10:04:43 +08:00
::: demo
<template>
<lay-form>
2021-11-18 00:45:22 +08:00
<lay-checkbox name="like" label="1" v-model="checked2" >普通</lay-checkbox>
2021-10-13 10:04:43 +08:00
</lay-form>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const checked2 = ref(false)
2021-10-13 10:04:43 +08:00
return {
checked2
2021-10-13 10:04:43 +08:00
}
}
}
</script>
:::
2021-11-19 00:42:26 +08:00
::: title 复选框组
:::
::: demo
<template>
<lay-form>
<lay-checkbox-group v-model="checkeds" @change="groupChange">
<lay-checkbox name="like" skin="primary" label="1">写作</lay-checkbox>
<lay-checkbox name="like" skin="primary" label="2">画画</lay-checkbox>
<lay-checkbox name="like" skin="primary" label="3">运动</lay-checkbox>
</lay-checkbox-group>
</lay-form>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const checkeds = ref(['1','2']);
const groupChange = function(val) {
console.log("回调:" + JSON.stringify(val))
}
return {
checkeds,
groupChange
}
}
}
</script>
:::
2021-10-26 01:13:23 +08:00
::: title 完整案例
2021-10-24 21:31:42 +08:00
:::
2021-10-12 16:22:26 +08:00
::: demo
<template>
<lay-form>
2021-11-18 00:45:22 +08:00
<lay-checkbox name="like" skin="primary" v-model="checked3" label="1">写作</lay-checkbox>
<lay-checkbox name="like" skin="primary" v-model="checked4" label="2">画画</lay-checkbox>
<lay-checkbox name="like" skin="primary" v-model="checked5" label="3">运动</lay-checkbox>
2021-10-12 16:22:26 +08:00
</lay-form>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const checked3 = ref(true);
const checked4 = ref(true);
const checked5 = ref(true);
2021-10-12 16:22:26 +08:00
return {
checked3, checked4, checked5
2021-10-12 16:22:26 +08:00
}
}
}
</script>
:::
2021-10-26 01:13:23 +08:00
::: title 禁用状态
2021-10-24 21:31:42 +08:00
:::
::: demo
<template>
<lay-form>
2021-11-18 00:45:22 +08:00
<lay-checkbox name="like" skin="primary" label="1" :disabled="disabled" v-model="checked6">禁用</lay-checkbox>
</lay-form>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const disabled = ref(true)
const checked6 = ref(false);
return {
disabled,checked6
}
}
}
</script>
2021-10-12 16:22:26 +08:00
:::
2021-10-12 16:22:26 +08:00
2021-10-26 01:13:23 +08:00
::: title 事件回调
2021-10-24 21:31:42 +08:00
:::
2021-10-12 16:22:26 +08:00
::: demo
<template>
<lay-form>
2021-11-18 00:45:22 +08:00
<lay-checkbox name="like" skin="primary" label="1" @change="change" v-model="checked7">回调</lay-checkbox>
2021-10-12 16:22:26 +08:00
</lay-form>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const checked7 = ref(true);
2021-10-12 16:22:26 +08:00
const change = function(isChecked) {
console.log("是否选中:" + isChecked)
}
return {
change,
checked7
2021-10-12 16:22:26 +08:00
}
}
}
</script>
:::
2022-01-10 01:17:03 +08:00
::: title Checkbox 属性
2021-10-24 21:31:42 +08:00
:::
2021-11-07 15:55:08 +08:00
::: table
| 属性 | 描述 | 可选值 |
| ------------------- | ------------- | -------------------- |
| name | 原始属性 name | -- |
| skin | 主题 | -- |
| label | 选中值 | -- |
2021-11-18 00:45:22 +08:00
| v-model | 是否选中 | `true` `false` |
| change | 切换事件 | isChecked : 当前状态 |
2021-11-07 15:55:08 +08:00
:::
2022-01-10 01:17:03 +08:00
::: title Checkbox 事件
:::
2021-11-07 15:55:08 +08:00
::: table
| 事件 | 描述 | 可选值 |
| ------ | -------- | -------------------- |
| change | 切换事件 | isChecked : 当前状态 |
2021-11-07 15:55:08 +08:00
:::
2021-12-16 17:57:59 +08:00
::: comment
2022-01-12 14:19:06 +08:00
:::
::: previousNext checkbox
2021-12-16 17:57:59 +08:00
:::