CSS 与 Joomla 捆绑的 Bootstrap 2.1.0 中的“Uncaught SyntaxError: Unexpected token {” 3.0

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14979755/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 21:43:01  来源:igfitidea点击:

"Uncaught SyntaxError: Unexpected token { " in Bootstrap 2.1.0 bundled with Joomla! 3.0

cssjoomlatwitter-bootstrap

提问by Cysioland

I'm using Joomla! 3.0, which has Twitter Bootstrap 2.1.0 included. I want to do my own Joomla! template, and I need to use dropdown menus. When I include following CSS/JS:

我正在使用 Joomla!3.0,其中包含 Twitter Bootstrap 2.1.0。我想做我自己的Joomla!模板,我需要使用下拉菜单。当我包含以下 CSS/JS 时:

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>    
<script type="text/javascript" src="<?php echo $this->baseurl ?>/media/jui/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<?php echo $this->baseurl ?>/media/jui/css/bootstrap.css"></script>
<link href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/css/Site.css" rel="stylesheet" type="text/css">
<link rel="shotcut icon" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/css/images/favicon.ico" type="image/x-icon">

I get following CSS error:

我收到以下 CSS 错误:

Uncaught SyntaxError: Unexpected token { 

in /media/jui/css/bootstrap.css, line 19

/media/jui/css/bootstrap.css,第 19 行

回答by Marko D

You have syntax error because you tried to include CSS file as it was JavaScript, so change

你有语法错误,因为你试图包含 CSS 文件,因为它是 JavaScript,所以改变

<script type="text/javascript" src="<?php echo $this->baseurl ?>/media/jui/css/bootstrap.css"></script>

to

<link href="<?php echo $this->baseurl ?>/media/jui/css/bootstrap.css" rel="stylesheet" type="text/css" />

Also close other link tags properly with />, not with just >

还可以使用 正确关闭其他链接标签/>,而不仅仅是使用>