默认情况下生成的enum字段如下:
<div class="layui-input-block">
<div name="status" id="status" value="active" ></div>
</div>
layui.use(["jquery", "xmSelect"], function() {
let value = layui.$("#source_type").attr("value");
let initValue = value ? value.split(",") : [];
layui.xmSelect.render({
el: "#source_type",
name: "source_type",
filterable: true,
initValue: initValue,
value: "active",
model: {"icon":"hidden","label":{"type":"text"}},
clickClose: true,
radio: true,
})
});
render函数部分应增加基础数据字段data,格式为name,value对象,name是显示名称,value是对应值。
layui.use(["jquery", "xmSelect"], function() {
let value = layui.$("#status").attr("value");
let initValue = value ? value.split(",") : [];
layui.xmSelect.render({
el: "#status",
name: "status",
filterable: true,
initValue: initValue,
data: [{'name':'Active', 'value':'active'},{'name':'Inactive', 'value':'inactive'}],
value: "active",
model: {"icon":"hidden","label":{"type":"text"}},
clickClose: true,
radio: true,
})
});
Was this helpful?
0 / 0