The selectable @wines
@wines/selectable选框组。
``json`
{
"navigationBarTitleText": "wux-selectable",
"usingComponents": {
"wux-selectable": "@wines/selectable"
}
}
`xml
color="light"
value="1"
defaultChecked
/>
color="stable"
value="2"
defaultChecked
/>
color="positive"
value="3"
defaultChecked
/>
color="calm"
value="4"
defaultChecked
/>
color="balanced"
value="5"
defaultChecked
/>
color="energized"
value="6"
defaultChecked
/>
color="assertive"
value="7"
disabled
defaultChecked
/>
color="royal"
value="8"
disabled
defaultChecked
/>
color="dark"
value="9"
disabled
defaultChecked
/>
value="1"
checked="{{ checked }}"
bind:change="onCheckboxChange"
/>
wux-class="checkbox"
type="radio"
value="{{ item.value }}"
checked="{{ value === item.value }}"
controlled
bind:change="onChange"
/>
`
`ts
import { SelectableOnChangeValue } from '@wines/selectable';
import './index.less';
Page({
data: {
items: [
{
value: '1',
label: 'Wux',
},
{
value: '2',
label: 'Weapp',
},
],
value: '1',
checked: false,
},
onCheckboxChange(e) {
console.log(e);
this.setData({
checked: e.detail.checked,
});
},
onChange(e) {
const detail = e.detail as SelectableOnChangeValue;
console.log(detail);
this.setData({
value: detail.value,
});
},
});
`
| 参数 | 类型 | 描述 | 默认值 |
| -------------- | --------------- | ------------------------------------------------------------------------------------------- | -------------- |
| prefixCls | string | 自定义类名前缀 | wux-selectable |string
| type | | 类型,可选值为 checkbox、radio、default | checkbox |string
| value | | 字段值 | - |boolean
| defaultChecked | | 默认是否选中,当 controlled 为 false 时才生效 | false |boolean
| checked | | 当前是否选中,当 controlled 为 true 时才生效 | false |boolean
| controlled | | 是否受控 说明文档 | false |boolean
| disabled | | 是否禁用 | false |string
| color | | 主题色,可选值为 light、stable、positive、calm、assertive、balanced、energized、royal、dark | balanced |string,object
| wrapStyle | | 自定义样式 | - |function
| bind:change | | change 事件触发的回调函数 | - |
| 名称 | 描述 |
| -------- | --------------------------------- |
| - | 自定义内容 (type=default`时生效) |
| icon-on | 自定义已选中的内容 |
| icon-off | 自定义未选中的内容 |
| 名称 | 描述 |
| --------------- | ------------ |
| wux-class | 根节点样式类 |
| wux-input-class | 选择框样式类 |