Jssor - Uncaught TypeError:无法读取属性' $ ScaleWidth'未定义的

时间:2016-03-07 16:04:02

标签: javascript width jssor uncaught-typeerror

我正在制作自己的jssor用于某些项目,我偶然发现了我已经看到一些人遇到问题的宽度问题。我找到this code来解决问题,但之后它没有以任何方式调整大小,只是在添加代码之前看起来像。

在chrome中使用f12帮助我找到下一个错误:" Uncaught TypeError:无法读取属性&$ 39; $ ScaleWidth'未定义"。我不知道应该在哪里找到它。以下是我的代码的外观(添加了上面链接的修复)。

        <script>
        jssor_1_slider_init = function() {
            var jssor_1_SlideoTransitions = [
                [{b:0,d:700,y:-124,e:{y:27}}],
                [{b:0,d:700,y:-124,e:{y:27}}],
                [{b:0,d:700,y:-124,e:{y:27}}],
            ];
            var jssor_1_options = {
                $AutoPlay: true,
                $SlideDuration: 1139,
                $DragOrientation: 2,
                $PlayOrientation: 2,
                $SlideEasing: $Jease$.$OutQuint,
                $CaptionSliderOptions: {
                    $Class: $JssorCaptionSlideo$,
                    $Transitions: jssor_1_SlideoTransitions
                },
                $ArrowNavigatorOptions: {
                    $Class: $JssorArrowNavigator$
                },
                $BulletNavigatorOptions: {
                    $Class: $JssorBulletNavigator$
                }
            };
            var jssor_1_slider = new $JssorSlider$("jssor_1", jssor_1_options);
            function ScaleSlider() {
                var refSize = jssor_1_slider.$Elmt.parentNode.clientWidth;
                if (refSize) {
                    refSize = Math.min(refSize, 1920);
                    jssor_1_slider.$ScaleWidth(refSize);
                }
                else {
                    window.setTimeout(ScaleSlider, 30);
                }
            }
            ScaleSlider();
            $Jssor$.$AddEvent(window, "load", ScaleSlider);
            $Jssor$.$AddEvent(window, "resize", ScaleSlider);
            $Jssor$.$AddEvent(window, "orientationchange", ScaleSlider);

            var jssor_slider1 = new $JssorSlider$("slider1_container", options);
            function ScaleSlider() {
                var bodyWidth = document.body.clientWidth;
                if (bodyWidth)
            jssor_slider1.$ScaleWidth(Math.min(bodyWidth, 1920));
                else
                window.setTimeout(ScaleSlider, 30);
            }
            ScaleSlider();
            $(window).bind("load", ScaleSlider);
            $(window).bind("resize", ScaleSlider);
            $(window).bind("orientationchange", ScaleSlider);
        };
    </script>

Jssor 1600px的宽度,在id为&#34; jssor_1&#34;的div中有所不同(不在此处包含的代码中)。我的CSS也说明所有文本都是居中的。

有人知道如何解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

使用&#39; $ ScaleWidth&#39;有些已被弃用,所以请改用

'$SetScaleWidth'