<div id="demo1" style="width: 502px;"></div>
<script>
var list = [
{value: "1", title: "李白" },
{value: "2", title: "杜甫" },
{value: "3", title: "贤心" },
]
var initValue = ["1"]
var demo1 = xmSelect.render({
el: '#demo1',
content: "<div id='transfer'></div>",
height: 'auto',
autoRow: true,
initValue: initValue,
data: list,
prop: { name: 'title' },
on: function(data){
if(!data.isAdd){
layui.transfer.reload('transfer', {
value: demo1.getValue('value')
})
}
}
})
layui.transfer.render({
id: 'transfer',
elem: '#transfer',
title: ['候选人', '获奖者'],
data: list,
value: initValue,
onchange: function(data, index){
if(index == 0){
demo1.append(data)
}else{
demo1.delete(data)
}
}
});
</script>