为什么轮播不滑动或重定向到空白页?

时间:2019-04-29 04:57:38

标签: angular bootstrap-4

我正在使用Bootstrap 4,在创建轮播幻灯片时遇到了问题。

当我单击下一个或上一个按钮时,它将重定向到一个空白页面。我该如何解决?

String.prototype.supplant = function (o) {
  return this.replace(/\${([^\${}]*)}/g,
    (a, b) => {
      var r = o[b];
      return typeof r === 'string' || typeof r === 'number' ? r : a;
    }
  );
};

string = "How now ${color} cow? {${greeting}}, ${greeting}, moo says the ${color} cow.";

string.supplant({color: "brown", greeting: "moo"});
=> "How now brown cow? {moo}, moo, moo says the brown cow."

1 个答案:

答案 0 :(得分:0)

您的代码似乎可以正常工作。

我已经用您的代码创建了一个演示(只是对img src进行了标记)

  

检查 WORKING STACKBLITZ

<div id="myCarousel" class="carousel slide" data-ride="carousel">

  <ul class="carousel-indicators">
    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
    <li data-target="#myCarousel" data-slide-to="1"></li>
  </ul>


  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="../../assets/img/gaming.jpg" alt="gaming" width="100%" height="500">
    </div>
    ...

  </div>



  <a class="carousel-control-prev" href="#myCarousel" data-slide="prev">
    <span class="carousel-control-prev-icon"></span>
  </a>
  <a class="carousel-control-next" href="#myCarousel" data-slide="next">
    <span class="carousel-control-next-icon"></span>
  </a>
</div>

请检查您是否具有正确的Bootstrap 4链接和脚本

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

或检查是否已正确安装引导程序

npm install bootstrap --save
npm install jquery --save
npm install popper.js --save

然后检查您的angular.json并添加如下内容

"styles": [   
    "node_modules/bootstrap/dist/css/bootstrap.min.css",
    "styles.css"
  ],
  "scripts": [  
    "node_modules/jquery/dist/jquery.min.js",
    "node_modules/popper.js/dist/umd/popper.min.js",
    "node_modules/bootstrap/dist/js/bootstrap.min.js"
  ],