Skip to content
On this page

多选上限

最多选择2个

html
<div id="demo1" class="xm-select-demo"></div>

<script>
var demo1 = xmSelect.render({
	el: '#demo1', 
	max: 2,
	data: [
		{name: '张三', value: 1, selected: true},
		{name: '李四', value: 2, selected: true},
		{name: '王五', value: 3},
	]
})
</script>

自定义选超的提示

html
<div id="demo2" class="xm-select-demo"></div>

<script>
var demo2 = xmSelect.render({
	el: '#demo2', 
	max: 2,
	maxMethod(seles, item){
		alert(`${item.name}不能选了, 已经超了`)
	},
	data: [
		{name: '张三', value: 1, selected: true},
		{name: '李四', value: 2, selected: true},
		{name: '王五', value: 3},
	]
})
</script>

自定义选超的闪烁颜色

html
<div id="demo3" class="xm-select-demo"></div>

<script>
var demo3 = xmSelect.render({
	el: '#demo3', 
	max: 2,
	theme: {
		maxColor: 'orange',
	},
	data: [
		{name: '张三', value: 1, selected: true},
		{name: '李四', value: 2, selected: true},
		{name: '王五', value: 3},
	]
})
</script>