Adapt.js - 未定义ADAPT_CONFIG

时间:2013-10-08 19:03:04

标签: javascript variables undefined

我收到错误“ADAPT_CONFIG未定义”但我在我的页面中包含了配置..

{% block javascripts %}
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script src="{{ asset('/bundles/dproc/assets/js/adapt.min.js') }}"></script>
    <script>
    // Edit to suit your needs.
    var ADAPT_CONFIG = {
     // Where is your CSS?
    path: 'assets/css/',

    // false = Only run once, when page first loads.
    // true = Change on window resize and page tilt.
    dynamic: true,

    // First range entry is the minimum.
    // Last range entry is the maximum.
    // Separate ranges by "to" keyword.
        range: [
        '0px    to 760px  = mobile.min.css',
        '760px  to 980px  = 720.min.css',
        '980px  to 1280px = 960.min.css',
        '1280px to 1600px = 1200.min.css',
        '1600px to 1940px = 1560.min.css',
    '1940px to 2540px = 1920.min.css',
    '2540px           = 2520.min.css'
     ]
    };
    </script>
    {% endblock %}

它被定义..但我不知道这个问题是什么?

2 个答案:

答案 0 :(得分:1)

在声明adapt_config变量

之后,您应该包含adapt.js脚本

答案 1 :(得分:1)

  <script src="{{ asset('/bundles/dproc/assets/js/adapt.min.js') }}"></script>

将其粘贴在:

 <script>
// Edit to suit your needs.
var ADAPT_CONFIG = {
 // Where is your CSS?
path: 'assets/css/',

// false = Only run once, when page first loads.
// true = Change on window resize and page tilt.
dynamic: true,

// First range entry is the minimum.
// Last range entry is the maximum.
// Separate ranges by "to" keyword.
    range: [
    '0px    to 760px  = mobile.min.css',
    '760px  to 980px  = 720.min.css',
    '980px  to 1280px = 960.min.css',
    '1280px to 1600px = 1200.min.css',
    '1600px to 1940px = 1560.min.css',
'1940px to 2540px = 1920.min.css',
'2540px           = 2520.min.css'
 ]
};
</script>
像这样:

  <script>
// Edit to suit your needs.
var ADAPT_CONFIG = {
 // Where is your CSS?
path: 'assets/css/',

// false = Only run once, when page first loads.
// true = Change on window resize and page tilt.
dynamic: true,

// First range entry is the minimum.
// Last range entry is the maximum.
// Separate ranges by "to" keyword.
    range: [
    '0px    to 760px  = mobile.min.css',
    '760px  to 980px  = 720.min.css',
    '980px  to 1280px = 960.min.css',
    '1280px to 1600px = 1200.min.css',
    '1600px to 1940px = 1560.min.css',
'1940px to 2540px = 1920.min.css',
'2540px           = 2520.min.css'
 ]
};
</script>
<script src="{{ asset('/bundles/dproc/assets/js/adapt.min.js') }}"></script>

:)