最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Unexpected token in bootstrap.min.js - Stack Overflow

programmeradmin7浏览0评论

I downloaded version 3.3.6, used their (Bootstrap's) sample file (see below) but get the error: uncaught syntaxError: Unexpected token {

. I added some hard returns to be sure which line was the potential problem:

html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}

Here's their file, with the links modified for my local file system:

<!DOCTYPE html>
<html lang="en">
 <head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* e first in the head; any other head content must e *after* these tags -->
<title>Bootstrap 101 Template</title>

<!-- Bootstrap -->
<link href="/programming/javascript/bootstrap-3.3.6-dist/css/bootstrap.min.css" rel="stylesheet">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
  <script src=".7.2/html5shiv.min.js"></script>
  <script src=".4.2/respond.min.js"></script>
<![endif]-->
  </head>
  <body>
    <h1>Hello, world!</h1>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src=".11.3/jquery.min.js"></script>
    <!-- Include all piled plugins (below), or include individual files as needed -->
    <script src="/programming/javascript/bootstrap-3.3.6-dist/css/bootstrap.min.css"></script>
  </body>

I downloaded version 3.3.6, used their (Bootstrap's) sample file (see below) but get the error: uncaught syntaxError: Unexpected token {

. I added some hard returns to be sure which line was the potential problem:

html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}

Here's their file, with the links modified for my local file system:

<!DOCTYPE html>
<html lang="en">
 <head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* e first in the head; any other head content must e *after* these tags -->
<title>Bootstrap 101 Template</title>

<!-- Bootstrap -->
<link href="/programming/javascript/bootstrap-3.3.6-dist/css/bootstrap.min.css" rel="stylesheet">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
  <script src="https://oss.maxcdn./html5shiv/3.7.2/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn./respond/1.4.2/respond.min.js"></script>
<![endif]-->
  </head>
  <body>
    <h1>Hello, world!</h1>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis./ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <!-- Include all piled plugins (below), or include individual files as needed -->
    <script src="/programming/javascript/bootstrap-3.3.6-dist/css/bootstrap.min.css"></script>
  </body>

Share Improve this question asked Jul 7, 2016 at 18:51 RonRon 2,5033 gold badges28 silver badges39 bronze badges 4
  • 2 Where in all of this is bootstrap.min.js"? – Amit Commented Jul 7, 2016 at 18:54
  • 5 You're trying to load CSS as JS. – Siguza Commented Jul 7, 2016 at 18:58
  • 1 instead of min.js in <script> you have min.css – dippas Commented Jul 7, 2016 at 18:59
  • 1 Totally right. My stupidity. – Ron Commented Jul 7, 2016 at 19:03
Add a ment  | 

1 Answer 1

Reset to default 13

This next to last line of your code is wrong:

This is how you reference a JS file.

<script src="/programming/javascript/bootstrap-3.3.6-dist/css/bootstrap.min.css"></script>

if you want to reference this CSS file correctly, use this code:

<link href="/programming/javascript/bootstrap-3.3.6-dist/css/bootstrap.min.css" rel="stylesheet" />
发布评论

评论列表(0)

  1. 暂无评论