使用FullCalendar的“未捕获的SyntaxError:意外的令牌。”

时间:2022-12-04 20:51:11

I am working with the jQuery FullCalendar plugin. I import like this:

我正在使用jQuery FullCalendar插件。我像这样导入:

<link rel="stylesheet" type="text/css" src="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/1.6.4/fullcalendar.print.css"></link>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/1.6.4/fullcalendar.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/1.6.4/fullcalendar.css"></script>

When I load the pahe with Chrome, if I open console I can see this error message:

当我用Chrome加载pahe时,如果我打开控制台,我会看到以下错误消息:

Uncaught SyntaxError: Unexpected token . cdnjs.cloudflare.com/ajax/libs/fullcalendar/1.6.4/fullcalendar.css:8

So the error seems to be in css file of the FullCalendar plugin, in this line:

所以错误似乎是在FullCalendar插件的css文件中,在这一行:

.fc {
direction: ltr;
text-align: left;
}

Why would that "." before "fc" be wrong? Any idea what's wrong?

为什么会这样“。”在“fc”出错之前?知道什么是错的吗?

1 个解决方案

#1


92  

It's a .css file, which means it's a Cascading Stylesheet and not a script. You want a <link> tag rather than a <script> one.

它是一个.css文件,这意味着它是一个级联样式表而不是脚本。您需要 标记而不是

<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/1.6.4/fullcalendar.css"/>

Attempting to load it using a <script> tag results in your CSS being interpreted as JavaScript, and throwing the error because it's invalid. You can't use a . at the start of a JavaScript identifier so it's not expecting to find one at that position in the "code".

尝试使用

#1


92  

It's a .css file, which means it's a Cascading Stylesheet and not a script. You want a <link> tag rather than a <script> one.

它是一个.css文件,这意味着它是一个级联样式表而不是脚本。您需要 标记而不是

<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/1.6.4/fullcalendar.css"/>

Attempting to load it using a <script> tag results in your CSS being interpreted as JavaScript, and throwing the error because it's invalid. You can't use a . at the start of a JavaScript identifier so it's not expecting to find one at that position in the "code".

尝试使用