单选组 KLRadioGroup

基本形式

<kl-radio-group source={source} value={value} on-select={console.log($event)} />
var component = new NEKUI.Component({
template: template,
data: {
source: [
{name: '一般贸易', id: 1},
{name: '海淘', id: 2},
{name: '直邮', id: 3},
{name: '保税', id: 4}
],
value: 2
}
});

数据绑定

<kl-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: [
{name: '一般贸易', id: 11},
{name: '海淘', id: 22},
{name: '直邮', id: 33},
{name: '保税', id: 44}
],
value: 3
}
});

表单项

<kl-form>
<kl-form-item title="跨境方式" tip="跨境方式">
<kl-radio-group source={source} value={value}/>
</kl-form-item>
</kl-form>
var component = new NEKUI.Component({
template: template,
data: {
source: [
{name: '一般贸易', id: 1},
{name: '海淘', id: 2},
{name: '直邮', id: 3},
{name: '保税', id: 4}
],
value: 1
}
});

禁用组件

<kl-radio-group source={source} disabled />
var component = new NEKUI.Component({
template: template,
data: {
source: [
{name: '一般贸易', id: 1},
{name: '海淘', id: 2},
{name: '直邮', id: 3},
{name: '保税', id: 4}
]
}
});

远程数据

<kl-radio-group service={@(this.service)} value={value}/>
var component = new NEKUI.Component({
template: template,
service: {
getList: function(params, success) {
NEKUI.ajax.request({
url: '/data/KLRadioGroup.json',
method: 'get',
type: 'json',
data: params,
success: success
});
}
},
data: {
value: 4
}
});

多行

<kl-radio-group source={source} value={value} block />
var component = new NEKUI.Component({
template: template,
data: {
source: [
{name: '一般贸易', id: 1},
{name: '海淘', id: 2},
{name: '直邮', id: 3},
{name: '保税', id: 4}
],
value: 2
}
});

插入模版

<kl-radio-group source={source} value={value} on-select={console.log($event)} />
var component = new NEKUI.Component({
template: template,
data: {
source: [
{
name: '一般贸易',
id: 1,
contentTemplate: '<kl-input class="kl-template" value="{this.$parent.data.test}"/>'
},
{name: '海淘', id: 2},
{name: '直邮', id: 3},
{name: '保税', id: 4}
],
value: 2,
test: '插入模版'
}
});

API

KLRadioGroup

KLRadioGroup

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 @=> 数据服务
[options.data.source.contentTemplate] string => 内容模板,用于支持复杂内容的自定义。

select 选择某一项时触发Event

Name Type Description
sender object 事件发送对象
selected object 当前选择