gpt4 book ai didi

javascript - 使用 angularjs 时轮播不工作?

转载 作者:行者123 更新时间:2023-11-29 14:46:00 25 4
gpt4 key购买 nike

我使用 CSS 制作了一个响应式图像 slider 。我用这个例子做到了 http://bootsnipp.com/snippets/featured/responsive-thumb-preview-in-carousel-indicators . slider 自动工作,除非我单击轮播,而不是滑动图像,它会转到另一个页面。如何阻止这个?是不是和angularjs冲突了?

这里是代码:

<div id="thumbnail-preview-indicators" class="carousel slide" data-ride="carousel">

<ol class="carousel-indicators">
<li data-target="#thumbnail-preview-indicators" data-slide-to="0" class="active">
<div class="thumbnail">
<img class="img-responsive" src="../assets/images/abstract_wallpaper_1.png" />
</div>
</li>
<li data-target="#thumbnail-preview-indicators" data-slide-to="1">
<div class="thumbnail">
<img class="img-responsive" src="../assets/images/435523.jpg" />
</div>
</li>
<li data-target="#thumbnail-preview-indicators" data-slide-to="2">
<div class="thumbnail">
<img class="img-responsive" src="../assets/images/wallpaper-1356336.jpg" />
</div>
</li>
</ol>
<div class="carousel-inner">
<div class="item slides active">
<div class="slide-1"></div>
<div class="container">
<div class="carousel-caption">
<h1>Hi there! How was your day?</h1>
<p>This is the slide 1. Next --></p>
<p><a class="btn btn-lg btn-primary" href="#/" role="button">I'm Fine</a></p>
</div>
</div>
</div>
<div class="item slides">
<div class="slide-2"></div>
<div class="container">
<div class="carousel-caption">
<h1>Welcome back! how do you do?</h1>
<p>This is slide 2. Moving on... </p>
<p><a class="btn btn-lg btn-primary" href="#/" role="button">Great! Thanks.</a></p>
</div>
</div>
</div>
<div class="item slides">
<div class="slide-3"></div>
<div class="container">
<div class="carousel-caption">
<h1>You are back again! Need anything?</h1>
<p>This is slide 3. And the last one</p>
<p><a class="btn btn-lg btn-primary" href="#/" role="button">Yes peace :)</a></p>
</div>
</div>
</div>
</div>
<a class="left carousel-control" href="#thumbnail-preview-indicators" role="button" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>
<a class="right carousel-control" href="#thumbnail-preview-indicators" role="button" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>
</div>

这是 app.js。

'use strict'

var app = angular.module('myWeb',
[
'ngRoute'
]);
console.log('app');
app.config(['$routeProvider', '$httpProvider', function ($routeProvider, $httpProvider) {
$routeProvider
.when('/',{
templateUrl: 'home.html',
controller: 'HomeController'
});
$routeProvider
.when('/signup',{
templateUrl: 'signup.html',
controller: 'SignupController'
});
$routeProvider
.when('/contact', {
templateUrl: 'contact.html',
controller: 'ContactController'
});
$routeProvider
.when('/about',{
templateUrl: 'about.html',
controller: 'aboutController'
});

$routeProvider
.when('/t-and-c-m',
{
activatetab: '#t-and-c-m'
});

}]);

我是否也需要在 angularjs 中进行配置才能解决这个问题?帮助将不胜感激,因为我是 angularjs 的初学者。

问题的css如下

#thumbnail-preview-indicators {
position: relative;
overflow: hidden;
}
#thumbnail-preview-indicators .slides .slide-1,
#thumbnail-preview-indicators .slides .slide-2,
#thumbnail-preview-indicators .slides .slide-3 {
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
}
#thumbnail-preview-indicators,
#thumbnail-preview-indicators .slides,
#thumbnail-preview-indicators .slides .slide-1,
#thumbnail-preview-indicators .slides .slide-2,
#thumbnail-preview-indicators .slides .slide-3 {
height: 480px;
}

#thumbnail-preview-indicators .slides .slide-1{
background-image: url(../assets/images/abstract_wallpaper_1.png);
}

#thumbnail-preview-indicators .slides .slide-2{
background-image: url(../assets/images/435523.jpg);
}

#thumbnail-preview-indicators .slides .slide-3{
background-image:url(../assets/images/wallpaper-1356336.jpg);
}

#thumbnail-preview-indicators .carousel-inner .item .carousel-caption {
top: 20%;
bottom: inherit;
}
#thumbnail-preview-indicators .carousel-indicators li,
#thumbnail-preview-indicators .carousel-indicators li.active {
position: relative;
width: 100px;
height: 8px;
}
#thumbnail-preview-indicators .carousel-indicators li > .thumbnail {
position: absolute;
top: 0;
width: 100px;
display: none;
opacity: 0;
left: 50%;
margin-top: -80px;
margin-left: -50px;
}
#thumbnail-preview-indicators .carousel-indicators li:hover > .thumbnail,
#thumbnail-preview-indicators .carousel-indicators li.active > .thumbnail {
display: block;
opacity: .8;
}
#thumbnail-preview-indicators .carousel-indicators li.active > .thumbnail:hover{
opacity: 1;
}
@media screen and (max-width : 480px) {
#thumbnail-preview-indicators .carousel-indicators li,
#thumbnail-preview-indicators .carousel-indicators li.active {
width: 50px;
height: 8px;
position: relative;
}
#thumbnail-preview-indicators .carousel-indicators li > .thumbnail {
width: 50px;
left: 50%;
margin-top: -50px;
margin-left: -25px;
}
}

最佳答案

Bootstrap Carousel 与 AngularJs 不兼容,因为它们在下一个/上一个按钮中使用了#。

您可以尝试重写 carousel.js 的 Bootstrap 代码或使用其他元素,例如: https://angular-ui.github.io/bootstrap/

关于javascript - 使用 angularjs 时轮播不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32816712/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com