首页 > 解决方案 > 我无法初始化 bootstrap-year-calendar

问题描述

你好

我尝试 init bootstrap-year-calendar ,我不知道为什么它不起作用。

在这种情况下,我下载了文件,但我尝试使用具有相同效果的 npm。

<!doctype html>
<html lang="en">

<head>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
  <link rel="stylesheet" type="text/css" href="bootstrap-year-calendar.css">

</head>

<body>
  <h1>Hello, world</h1>
  <div data-provide="calendar"></div>

</body>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
<script src="bootstrap-year-calendar.js"></script>

<script>

      $('#calendar').calendar();

</script>
</html>

标签: javascripthtmltwitter-bootstrap

解决方案


您必须在 dom 内容加载完成后调用该函数。所以试试这个

$( document ).ready(function() {
   $('#calendar').calendar();
});

推荐阅读