YUI 拇指滑块不接受变量和表达式

YUI thumb slider does not accept variables and expressions

本文关键字:变量 表达式 不接受 YUI      更新时间:2023-09-26

我已经使用yui/alloyui制作了一个拇指滑块。根据 UC,滑块中的最小和最大参数应该动态传递,这意味着我无法在脚本中对它们进行硬编码。查看规格,它说滑块最小值、最大值、值参数仅接受数字,不接受表达式。谁能帮我做到这一点?

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

感谢您的帮助!

如果你使用整数变量,它应该可以工作。 例如

   // 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
});