判断bootstrap.js是否加载完成

2025-05-13 08:56:21
推荐回答(1个)
回答1:

bootstrap3的 JavaScript 组件

  • Component animations

  • Dropdown

  • Tooltip

  • Popover

  • Modal

  • Carousel

如果使用了bootstrap的组件,比如Modal,会注册到jQuery.fn

if (typeof jQuery === 'undefined') {
  throw new Error('requires jQuery');
}
if (typeof jQuery.fn.modal === 'undefined') {
  throw new Error('requires bootstrap.modal');
}

这样可以判断是否加载了bootstrap,要是判断加载完成,加个定时器?