代码演示
基本形式
<radio.group source={source} />
var component = new NEKUI.Component({template: template,data: {source: [{name: '选项1'},{name: '选项2'},{name: '选项3'},{name: '选项4'},{name: '选项5'},{name: '选项6'}]}});
数据绑定
<radio.group source={source} value={value} selected={selected} /><div>value: {value}</div><div>selected: {selected ? JSON.stringify(selected) : ''}</div>
var component = new NEKUI.Component({template: template,data: {source: [{id: 11, name: '选项1'},{id: 22, name: '选项2'},{id: 33, name: '选项3'},]}});
表单项
在表单中使用
<ui.form><form.item cols="12" title="用户名" hint="用户名的用途"><radio.group source={source} /></form.item></ui.form>
var component = new NEKUI.Component({template: template,data: {source: [{name: '选项1'},{name: '选项2'},{name: '选项3'},{name: '选项4'},{name: '选项5'},{name: '选项6'}]}});
禁用组件
<radio.group source={source} disabled />
var component = new NEKUI.Component({template: template,data: {source: [{name: '选项1'},{name: '选项2'},{name: '选项3'},{name: '选项4'},{name: '选项5'},{name: '选项6'}]}});
远程数据
<radio.group service={@(this.service)} />
var component = new NEKUI.Component({template: template,service: {getList: function(params, success) {NEKUI.ajax.request({url: '../data/list.json',method: 'get',type: 'json',data: params,success: success});}}});
多行
<radio.group source={source} block />
var component = new NEKUI.Component({template: template,data: {source: [{name: '选项1'},{name: '选项2'},{name: '选项3'},{name: '选项4'},{name: '选项5'},{name: '选项6'}]}});
API
Classes
Functions
- config()
- select(item) 选择某一(item) 选择某一) ⇒
void
- validate() 根据required验证组件的值是否正确() ⇒
object
Events
RadioGroup
Kind: global classExtend: SourceComponent
new RadioGroup()
Param | Type | Default | Description |
---|---|---|---|
[options.data] | object | = 绑定属性 | |
[options.data.source] | Array.<object> | [] | <=> 数据源 |
[options.data.nameKey] | string | "name" | => 数据项的name键 |
[options.data.key] | string | "id" | => 数据项的key键 |
[options.data.source[].name] | string | => 每项的内容 | |
[options.data.selected] | object | <=> 当前选择的对象 | |
[options.data.value] | number | string | <=> 当前选择的值 | |
[options.data.block] | boolean | false | => 多行显 |
[options.data.required] | boolean | false | => 是否必选 |
[options.data.message] | string | => 验证错误提示 | |
[options.data.hideTip] | boolean | false | => 是否显示校验错误信息 |
[options.data.readonly] | boolean | false | => 是否只读 |
[options.data.disabled] | boolean | false | => 是否禁用 |
[options.data.visible] | boolean | true | => 是否显 |
[options.data.class] | string | => 补充class | |
[options.service] | object | @=> 数据服务 |
config()
Kind: global functionAccess: protected
select(item) 选择某一(item) ⇒ void
Kind: global functionAccess: public
Param | Type | Description |
---|---|---|
item | object | 选择 |
validate() 根据required验证组件的值是否正确() ⇒ object
Kind: global functionReturns: object
- result 结果Access: public
“select 选择某一项时触发”
Kind: event emittedProperties
Name | Type | Description |
---|---|---|
sender | object | 事件发送对象 |
selected | object | 当前选择 |