0

I am using carousel of bootstrap v4 in a vue webapp. I am using as it is in the sample example, but it is not working in my local, neither it is giving any error.

<div class="col-xs-5 card prod-img">
  <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
    <ol class="carousel-indicators">
      <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
      <li data-target="#carousel-example-generic" data-slide-to="1"></li>
      <li data-target="#carousel-example-generic" data-slide-to="2"></li>
    </ol>
    <div class="carousel-inner" role="listbox">
      <div class="carousel-item active">
        <img src="../../assets/animals/rat.png" alt="First slide">
      </div>
      <div class="carousel-item">
        <img src="../../assets/animals/cat.png" alt="Second slide">
      </div>
      <div class="carousel-item">
        <img src="../../assets/animals/dog.png" alt="Third slide">
      </div>
    </div>
    <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
      <span class="icon-prev" aria-hidden="true"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
      <span class="icon-next" aria-hidden="true"></span>
      <span class="sr-only">Next</span>
    </a>
  </div>
</div>

I am using Vue with Vue-router, however it works well when I try it in jsfiddle: here with vue-router and here without router.

I already have jquery and tether in my index.html along with bootstrap as shown following:

<link rel="stylesheet" href="/static/bootstrap.css" type="text/css">
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.3.7/js/tether.min.js" integrity="sha384-XTs3FgkjiBgo8qjEjBk0tGmf3wPrWtA6coPfQDfFEY8AnYJwjalXCiosYRBIBZX8" crossorigin="anonymous"></script>
<script src="https://use.fontawesome.com/89588fe8fc.js"></script>
<script  href="/static/bootstrap.js"></script>

Please help what can be the error in my local setup, what other details should I provide which can be helpful to understand this problem.

There are no errors in the console.

I see left and right arrows also on the image, as attached below, but nothing happens when I click on those but URL changes to http://localhost:8080/myUrl#carousel-example-generic from http://localhost:8080/myUrl

enter image description here

Here is my index.html:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta http-equiv="x-ua-compatible" content="ie=edge">

    <title>Hey</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
    <link href='https://fonts.googleapis.com/css?family=Roboto:300,400,700' rel='stylesheet' type='text/css'>

    <link rel="stylesheet" href="/static/bootstrap.css" type="text/css">

    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.3.7/js/tether.min.js" integrity="sha384-XTs3FgkjiBgo8qjEjBk0tGmf3wPrWtA6coPfQDfFEY8AnYJwjalXCiosYRBIBZX8" crossorigin="anonymous"></script>    <!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js" integrity="sha384-BLiI7JTZm+JWlgKa0M0kGRpJbF2J8q+qreVrKBC47e3K6BW78kGLrCkeRX6I9RoK" crossorigin="anonymous"></script> -->
    <script src="https://use.fontawesome.com/89588fe8fc.js"></script>
    <script  href="/static/bootstrap.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/jssor-slider/21.1.5/jssor.slider.min.js"></script>
  </head>
  <body>
    <div id="app"></div>
  </body>
</html>

I have put my whole code here, which can be cloned and tested in local.

Saurabh
  • 71,488
  • 40
  • 181
  • 244
  • boostrap js path is correct /static/bootstrap.js? – Vel Dec 08 '16 at 14:26
  • Yes, It is correct, I can use other features, like card etc. – Saurabh Dec 08 '16 at 14:37
  • what is the error in console? – Vel Dec 08 '16 at 14:43
  • @vel: I have updated the question, there are no error on console.I see the left/right arrow, but nothing happens other than change in URL. – Saurabh Dec 08 '16 at 16:49
  • Where are you placing the script tags? Inside the `` or before ``? – Ethan Dec 08 '16 at 16:55
  • @TheLazySloth It is inside ``, I have also pasted `index.html`. – Saurabh Dec 08 '16 at 17:20
  • seems boostrap js not loading properly. please check – Vel Dec 08 '16 at 18:17
  • change src="//cdnjs. to src="http://cdnjs. – Vel Dec 08 '16 at 18:17
  • @vel No, it loads properly when I have `//cdn` as now I am gettting an error in console that ` http://localhost:8080/myAPI/cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js ` not Found. Also earlier I was seeing three images on top of each other with left/right arrow, now they are one after another. I believe it is working properly with `//cdn` – Saurabh Dec 09 '16 at 02:54
  • Have you tried moving it before `

    `? For reference: http://stackoverflow.com/a/10994391

    – Ethan Dec 09 '16 at 04:01
  • Yes. Its not working in my localhost – Vel Dec 09 '16 at 05:36
  • @TheLazySloth I have put my complete code [here](https://github.com/mimani/vue-example), I have tried your suggestion as well, but same issue, no error, carousel not working. Anyone can clone [this repo](https://github.com/mimani/vue-example) and try in local. – Saurabh Dec 09 '16 at 06:24

2 Answers2

5

updated

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta http-equiv="x-ua-compatible" content="ie=edge">

    <title>Hey</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
    <link href='https://fonts.googleapis.com/css?family=Roboto:300,400,700' rel='stylesheet' type='text/css'>



    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.3.7/js/tether.min.js" integrity="sha384-XTs3FgkjiBgo8qjEjBk0tGmf3wPrWtA6coPfQDfFEY8AnYJwjalXCiosYRBIBZX8" crossorigin="anonymous"></script>    <!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js" integrity="sha384-BLiI7JTZm+JWlgKa0M0kGRpJbF2J8q+qreVrKBC47e3K6BW78kGLrCkeRX6I9RoK" crossorigin="anonymous"></script> -->
    <script src="https://use.fontawesome.com/89588fe8fc.js"></script>
    <link rel="stylesheet" href="static/bootstrap.css" type="text/css">
    <script  href="static/bootstrap.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/jssor-slider/21.1.5/jssor.slider.min.js"></script>
  </head>
  <body>
    <div id="app"></div>
  </body>
</html>

change these lines

<link rel="stylesheet" href="static/bootstrap.css" type="text/css">
<script  href="static/bootstrap.js"></script>

Instead of

<link rel="stylesheet" href="/static/bootstrap.css" type="text/css">
<script  href="/static/bootstrap.js"></script>
Vel
  • 9,027
  • 6
  • 34
  • 66
2

The error is here.

<script  href="/static/bootstrap.js"></script>

HREF, should be SRC, and all works fine :).