xm-select/docs/mds/XM18.md
2019-11-19 20:13:50 +08:00

1.1 KiB

多选上限

最多选择2个

:::demo

<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>

:::

自定义选超的提示

:::demo

<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>

:::

自定义选超的闪烁颜色

:::demo

<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>

:::