html中carousel报错怎么解决,javascript - 无法使用Bootstrap Carousel读取未定义的属性'offsetWidth' - 堆栈内存溢出...

我有一个Bootstrap Carousel,但有一些问题。 我尝试使用其他类似的解决方案,但我无法解决我的情况...

此图显示了页面上的错误:

aHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9TYTZWcy5wbmc=

HTML代码

Boostrap JS行错误

$next[0].offsetWidth // force reflow

return this.slide('next')

return fn.apply( context || this, args.concat( slice.call( arguments ) ) );

$ next错误代码行(其中初始化$ error)。 我认为这是代码的一部分。

Carousel.prototype.slide = function (type, next) {

var $active = this.$element.find('.item.active')

var $next = next || this.getItemForDirection(type, $active)

var isCycling = this.interval

var direction = type == 'next' ? 'left' : 'right'

var fallback = type == 'next' ? 'first' : 'last'

var that = this

if (!$next.length) {

if (!this.options.wrap) return

$next = this.$element.find('.item')[fallback]()

}

if ($next.hasClass('active')) return (this.sliding = false)

var relatedTarget = $next[0]

var slideEvent = $.Event('slide.bs.carousel', {

relatedTarget: relatedTarget,

direction: direction

})

this.$element.trigger(slideEvent)

if (slideEvent.isDefaultPrevented()) return

this.sliding = true

isCycling && this.pause()

if (this.$indicators.length) {

this.$indicators.find('.active').removeClass('active')

var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)])

$nextIndicator && $nextIndicator.addClass('active')

}

var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"

if ($.support.transition && this.$element.hasClass('slide')) {

$next.addClass(type)

$next[0].offsetWidth // force reflow

$active.addClass(direction)

$next.addClass(direction)

$active

.one('bsTransitionEnd', function () {

$next.removeClass([type, direction].join(' ')).addClass('active')

$active.removeClass(['active', direction].join(' '))

that.sliding = false

setTimeout(function () {

that.$element.trigger(slidEvent)

}, 0)

})

.emulateTransitionEnd(Carousel.TRANSITION_DURATION)

} else {

$active.removeClass('active')

$next.addClass('active')

this.sliding = false

this.$element.trigger(slidEvent)

}

isCycling && this.cycle()

return this

}

非常感谢你!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值