直接上代码
xm-select.js下载地址https://pan.baidu.com/s/1YXDsr9tn8EOeX0vEzPwGdQ?pwd=nvdv
提取码:nvdv
第一步: 下载
第二步: 引入 xm-select.js
第三步: 写一个`<div id="demo1"></div>`
第四步: 渲染
var demo1 = xmSelect.render({
el: '#demo1',
language: 'zn',
data: [
{name: '张三', value: 1},
{name: '李四', value: 2},
{name: '王五', value: 3},
]
})
<div id="demo1" class="xm-select-demo"></div>
<button class="btn" id="demo1-getValue">获取选中值</button>
<pre id="demo1-value"></pre>
<script>
var demo1 = xmSelect.render({
el: '#demo1',
language: 'zn',
data: [
{name: '张三', value: 1},
{name: '李四', value: 2},
{name: '王五', value: 3},
]
})
document.getElementById('demo1-getValue').onclick = function(){
//获取当前多选选中的值
var selectArr = demo1.getValue();
document.getElementById('demo1-value').innerHTML = JSON.stringify(selectArr, null, 2);
}
</script>
标签:name,xm,layui,value,demo1,var,select
From: https://www.cnblogs.com/79524795-Tian/p/18117857