我正在使用yui / alloyui处理拇指滑块。根据UC,滑块中的min和max参数应该动态传递,这意味着我不能在脚本中对它们进行硬编码。回顾一下规格,它说滑块min,max,value参数只接受数字,而不接受表达式。任何人都可以帮助我实现这个目标吗?
<code>
mySlider = new Y.Slider({
//min: 100, This works
//max: 800, This works
//value: 300, This works
min: minValue, //Using a variable does not work
max: maxValue, //Using a variable does not work
value: (maxValue - minValue)/2, //Using an expression does not work
majorStep: 50,
minorStep: 50,
length: Y.one('#sliderParent').getComputedStyle('width')
});
</code>
这是jsfiddle:http://jsfiddle.net/bpkscskg/
感谢您的帮助!
答案 0 :(得分:0)
如果你使用整数变量,它应该工作。例如
// my Variables
var myMin=+valMinAmount;
var myMax=+valMaxAmount;
xSlider = new Y.Slider({
//min:100,
min: myMin,
max: myMax,
//value:
majorStep: 50, //amount to increment/decrement the Slider value when the page up/down keys are pressed
minorStep: 50, //amount to increment/decrement the Slider value when the arrow up/down/left/right keys are pressed
length: Y.one('#sliderParent').getComputedStyle('width') // for responsiveness
});