【发布时间】:2014-12-02 19:50:02
【问题描述】:
我正在构建一个需要实施轮播的网站。因为这个网站是建立在 AngularJS 上的,所以我想使用 Angulars Boostrap Carousel,但是,这个轮播似乎一次只允许一张图片。
我需要在台式机上一次 3 张图片,在平板电脑上 2 张图片和在移动设备上 1 张。所以这里也涉及到响应式设计的重要元素。
有没有人有任何不涉及 JQuery 的经验?我并不反对,但团队的一位高级成员告诉我要尝试寻找替代方案(如果有的话)。
我从 Angulars 引导程序中尝试过的内容:
$scope.getPromoURLs = function() {
var subObj = myJSON.response.details.promotionalSpots;
for( var keys in subObj ) {
var value = subObj[keys].promotionUrl;
$scope.slides.push( value );
}
};
// Builts an array of promotional URLS to from a JSON object to source the images
$scope.getPromoURLs();
$scope.addSlide = function () {
// Test to determine if 3 images can be pulled together - FAILS
var newWidth = 600 + slides.length;
slides.push({
image: ''+slides[0]+''+slides[1] // etc
// Tried to stitch images together here
});
};
// TODO Should examine array length not hardcoded 4
for (var i = 0; i < 4; i++) {
$scope.addSlide();
}
【问题讨论】:
-
Should I use a carousel?(剧透:答案是否定的)。轮播真的、真的有必要吗?
-
@GregL 嗨,格雷格,是的,我之前读过,不幸的是,这是业务的要求,并且已经受到开发人员的质疑 - 他们坚持使用它
-
你可以看看github.com/gilbitron/carouFredSel。这是一个响应式轮播(唉,建立在 jQuery 之上)
-
@Katana24 -- 我使用owlgraphic.com/owlcarousel/demos/itemsCustom.html(这是此轮播的第 1 版,第 2 版更好,但在 Beta 版中,我不会在生产中使用)。
标签: javascript css angularjs angular-ui-bootstrap