Javascript FullCalendar TypeError: $(...).fullCalendar 不是函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26252938/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
FullCalendar TypeError: $(...).fullCalendar is not a function
提问by Tiago Ribeiro
I was trying to put FullCalendar 2.1.1 but it is not working:
我试图放置 FullCalendar 2.1.1 但它不起作用:
<link href='/css/fullcalendar.css' rel='stylesheet' />
<link href='/css/fullcalendar.min.css' rel='stylesheet' />
<link href='/css/fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='/js/moment.min.js'></script>
<script src='/js/jquery.min.js'></script>
<script src='/js/fullcalendar.min.js'></script>
<script src="/js/jquery-ui.custom.min.js"></script>
<script>
$(document).ready(function() {
$('#calendar').fullCalendar({
defaultDate: '2014-09-12',
editable: true,
eventLimit: true, // allow "more" link when too many events
});
});
</script>
When I go to try open it I get the following errors:
当我去尝试打开它时,我收到以下错误:
SyntaxError: missing ) after argument list ..."'").replace(/"/g,""").replace(/\n/g,"")}function P(t){returnt.replace(/
TypeError: $(...).fullCalendar is not a function
eventLimit: true, // allow "more" link when too many events
I have followed the Basic Usage Documentation but it still doesn't work.
我已经遵循了基本使用文档,但它仍然不起作用。
回答by Rohan Kumar
I think you have problem with js try the below urls it may solve your problems,
我认为您对 js 有问题尝试以下网址可能会解决您的问题,
<script src='http://fullcalendar.io/js/fullcalendar-2.1.1/lib/moment.min.js'></script>
<script src='http://fullcalendar.io/js/fullcalendar-2.1.1/lib/jquery.min.js'></script>
<script src="http://fullcalendar.io/js/fullcalendar-2.1.1/lib/jquery-ui.custom.min.js"></script>
<script src='http://fullcalendar.io/js/fullcalendar-2.1.1/fullcalendar.min.js'></script>
<script>
$(document).ready(function() {
$('#calendar').fullCalendar({
defaultDate: '2014-09-12',
editable: true,
eventLimit: true, // allow "more" link when too many events
});
});
</script>
If the above code works then download the js files used in script tag
如果上述代码有效,则下载脚本标签中使用的 js 文件
回答by Abhijit Jagtap
I also had same problem and it was because the HTML jQuery file was loading twice, hence it was giving me error.
我也有同样的问题,这是因为 HTML jQuery 文件加载了两次,因此它给了我错误。
回答by Alan García
I've solved the problem simply changing order of my scripts. You must be set:
moment.min.jsafter jquery.min.jslook this:
我已经解决了这个问题,只是改变了我的脚本的顺序。你必须设置:
moment.min.js后jquery.min.js看这个:
<script src='/js/jquery.min.js'></script>
<script src='/js/moment.min.js'></script>
<script src='/js/fullcalendar.min.js'></script>
回答by Vedran
If using ES6 syntax, just add this at the start of your file:
如果使用 ES6 语法,只需在文件开头添加:
import "fullcalendar";
回答by Mohammad Hossein Nik-khah
I had the same problem. I used sitemeshand decorators.
the problem solved when I injected the JS script's links twiceboth in the decorator and the webpage!
The order is important too,use following order:
我有同样的问题。我使用了站点网格和装饰器。
当我在装饰器和网页中两次注入 JS 脚本的链接时,问题解决了!
顺序也很重要,使用以下顺序:
<script src="../../resource/bower_components/jquery/dist/jquery.min.js"></script>
<script src="../../resource/bower_components/jquery-ui/jquery-ui.min.js"></script>
<script src="../../resource/dist/js/demo.js"></script>
<script src="../../resource/bower_components/moment/moment.js"></script>
<script src="../../resource/bower_components/fullcalendar/dist/fullcalendar.min.js"></script>

