javascript “未捕获的语法错误:意外的令牌。” 使用完整日历
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19836615/
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
"Uncaught SyntaxError: Unexpected token ." with FullCalendar
提问by Xar
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”之前有错吗?知道出了什么问题吗?
回答by Anthony Grist
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>
标签而不是<script>
一个。
<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".
尝试使用<script>
标签加载它会导致您的 CSS 被解释为 JavaScript,并因为它无效而抛出错误。您不能.
在 JavaScript 标识符的开头使用 a ,因此它不会期望在“代码”中的该位置找到一个。