javascript - 我无法初始化 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>
解决方案
您必须在 dom 内容加载完成后调用该函数。所以试试这个
$( document ).ready(function() {
$('#calendar').calendar();
});
推荐阅读
- python - 为什么这段代码没有通过逻辑测试
- python - 如何更改熊猫数据框结构?
- python - 运行后如何重置到代码的开头?
- python - 在 Pandas Dataframe 中清理单元格值的最佳方法
- php - PHP没有从JSON接收POST参数
- windows - 我可以创建一个只提取几个 IP 之一的批处理程序吗?
- jvm-hotspot - CMS GC如何保证并发扫描时不清除新的引用
- python - 检查 datetimeindex 是否属于另一个日期列表并应用条件
- javascript - 22/7 的计算差异
- dataframe - 如何使用 spark DataFrame groupBy 而不是 agg?