为nouislider设置新值已达到最大数量

Set new value for nouislider is reached max number

本文关键字:最大数 nouislider 设置 新值      更新时间:2023-09-26

美好的一天,

如果滑块达到最大值 2000,是否可以将预定义的字符串值设置为此。

这是我的代码

noUiSlider.create(connectSlider, {
	start: 300,
	step: 5,
	connect: 'lower',
	range: {
	  'min': 0,
	  'max': 2000
	},
	format: wNumb({
		decimals: 0,
		thousand: ',',
		prefix: '$',
		postfix: ' per month',
	}),
});

http://refreshless.com/nouislider/slider-options/

谢谢

您可以在格式化程序中使用 edit 函数。它在应用所有其他格式选项运行。

format: wNumb({
    decimals: 0,
    thousand: ',',
    prefix: '$',
    postfix: ' per month',
    edit: function ( value ) {
        return value == yourMaxValue ? 'Maximum reached!' : value;
    }
})

供参考:所有格式选项。