2

我正在尝试将 bootstrap.js 添加到我的要求配置中。大约每 20 次刷新,我Uncaught TypeError: undefined is not a function在第 23 行收到一个错误,这是我的文档准备好:$(function () {

我阅读了此修复程序,这导致我在下面设置了 require.config。

require.config({
  paths: {
    jquery: 'libs/jquery/jquery-min',
    underscore: 'libs/underscore/underscore-min',
    backbone: 'libs/backbone/backbone-min',
    templates: '../templates',
    bootstrap: 'libs/bootstrap/bootstrap'
  },
  shim: {
      backbone: {
          deps: ['underscore', 'jquery'],
          exports: 'Backbone'
      },
      underscore: {
          exports: '_'
      },
      bootstrap: {
          deps: ['jquery'],
          exports: "$.fn.popover"
      },
      enforceDefine: true
  }

});

require([
  'ripple',    
], function(Ripple){
    Ripple.initialize();
});

波纹.js

// Filename: ripple.js
define([
  'jquery',
  'underscore',
  'backbone',
  'router', // Request router.js
  'bootstrap'
], function ($, _, Backbone, Router, Bootstrap) {
    var initialize = function () {
        // Pass in our Router module and call it's initialize function
        Router.initialize();
    }

    return {
        initialize: initialize
    };
});

我假设这是引导程序偶尔会失败的竞争条件。有任何想法吗?

4

0 回答 0