gpt4 book ai didi

javascript - angular ui bootstrap carousel 中没有过渡

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:02:15 25 4
gpt4 key购买 nike

我在这里重新使用了基于 Angular 轮播: http://codepen.io/hamzaisaac/pen/avaVYK

标记:

<div ng-app="MyApp">
<div ng-controller="CarouselDemoCtrl">
<div style="height: 305px">
<uib-carousel interval="myInterval" no-wrap="noWrapSlides">
<uib-slide ng-repeat="slide in slides" active="slide.active">
<img ng-src="{{slide.image}}" style="margin:auto;">
<div class="carousel-caption">
<h4>Slide {{$index}}</h4>
<p>{{slide.text}}</p>
</div>
</uib-slide>
</uib-carousel>
</div>
</div>
</div>

Controller :

 angular.module('MyApp', ['ui.bootstrap'])
.controller('CarouselDemoCtrl', function ($scope) {
$scope.myInterval = 5000;
$scope.noWrapSlides = false;
var slides = $scope.slides = [];
$scope.addSlide = function() {
var newWidth = 1000 + slides.length + 1;
slides.push({
image: '//placekitten.com/' + newWidth + '/300',
text: ['More','Extra','Lots of','Surplus'][slides.length % 4] + ' ' +
['Cats', 'Kittys', 'Felines', 'Cutes'][slides.length % 4]
});
};
for (var i=0; i<4; i++) {
$scope.addSlide();
}
});

可以,但是我在原代码中无法实现相同的过渡效果: https://angular-ui.github.io/bootstrap/#carousel

为什么?我已经包含了所有依赖项,包括 Angularjs 和 UI Bootstrap。我在这里遗漏了什么吗?

最佳答案

您缺少 ng-animate 依赖项。

angular.module('MyApp', ['ngAnimate', 'ui.bootstrap'])

如果您使用的是 bower,那么只需使用以下命令安装依赖项

bower install angular-animate

或者使用 npm

npm install angular-animate

并在您的 index.html 中包含 js

<script src="/path/to/angular-animate/angular-animate.js"></script>

关于javascript - angular ui bootstrap carousel 中没有过渡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33597498/

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