基础5 /显示模态错误/未捕获TypeError:无法读取未定义的属性'css'

Kir*_*i35 4 html javascript css jquery zurb-foundation

我正在使用Foundation 5作为我的Web应用程序.现在,当我尝试调用模态时,我得到JS错误:

未捕获的TypeError:无法读取未定义的属性'css'"**

在控制台中.即使在基金会博客/支持中,我也无法找到任何可能的解决方案.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="width=device-width, height=device-height"> 
    <link rel="stylesheet" type="text/css" href="css/index.css" />
    <link rel="stylesheet" href="css/foundation.min.css" />
    <link rel="stylesheet" href="css/swiper.css">
    <script src="js/modernizr.js"></script>
    <title>Test code</title>
</head>
<body> 
      <a href="#" data-reveal-id="myModal" data-reveal>Click Me For A Modal</a>

        <div id="firstModal" class="reveal-modal" data-reveal>
      <h2>Awesome. I have it.</h2>
      <p class="lead">Your couch.  It is mine.</p>
      <p>Im a cool paragraph that lives inside of an even cooler modal. Wins</p>
      <a class="close-reveal-modal">&#215;</a>
    </div>

    <script type="text/javascript" src="js/index.js"></script>
    <script src="js/jquery.js"></script>  
    <script src="js/foundation.min.js"></script> 

     <script>
      $(document).foundation();
      /*Fix for Sticky footer and List to Be displayed properly in Sidebar*/          
      $(function() {
        var timer;
        $(window).resize(function() {
            clearTimeout(timer);
            timer = setTimeout(function() {
                $('.inner-wrap').css("min-height", $(window).height() + "px" );
            }, 40);
        }).resize();
      });
    </script>
    <!-- Modal -->

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

jph*_*ase 8

此示例的问题是您的data-reveal-id ="myModal"属性与揭密模式的id ="firstModal"属性不匹配.一旦匹配,您就不应再看到此错误.

此外,您的锚标记不需要data-reveal属性,只有模态本身需要它.

@BobbySales:其他事情也可能导致这种情况......就像你错误输入数据显示属性一样.如果data-reveal属性丢失或者data-reveal-id与模态的id不匹配,那么这将会中断.如果您使用javascript打开模态并且出现此错误,请确保您的数据显示属性中没有拼写错误.另一件可能导致这种情况的是,如果$(document).foundation()调用在页面上显示模态之前发生.

希望这可以帮助.