本文介绍了在requirejs中正确加载依赖项(autobahn和whenjs)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去几个小时我一直坚持这个问题。我正在尝试通过requirejs正确加载autobahnjs和whenjs。

I have been stuck on this problem for the past few hours. I'm trying to get autobahnjs and whenjs to be loaded correctly by requirejs.

require.config({
    paths: {
        angular:            '../bower_components/angular/angular',
        angularBootstrap:   '../bower_components/angular-bootstrap/ui-bootstrap',
        bootstrap:          '../bower_components/bootstrap/dist/js/bootstrap',
        jquery:             '../bower_components/jquery/jquery',
        chosen:             '../bower_components/chosen/chosen.jquery.min',
        text:               '../bower_components/requirejs-text/text',
        autobahn:           '../bower_components/autobahnjs/autobahn/autobahn'

    },
    packages: [
       { name: 'when', location: '../bower_components/when/', main: 'when' }
    ],
    baseUrl: '/bundles/example/app/scripts/',
    shim: {
        angular : { 
            exports : 'angular'
        },
        angularBootstrap: {
            deps: ['angular']
        },
        autobahn: {
            deps: ['when']
        }
    },
    priority: [
        'angular'
    ]
});

require
( [
    'angular',
    'app',
    'autobahn',
    'angularBootstrap',
    'jquery',
    'bootstrap',
    'chosen',
    'controllers/event',
    'services/notify'
], function(angular, app) {
    // more code here
});

Autobahnjs依赖于whenjs。加载所有文件(并按正确的顺序)。但始终未定义时。我完全不知道我做错了什么。我已经尝试了各种方法来解决它。我还有一个文件,如果这有助于任何人复制问题。提前致谢。

Autobahnjs has a dependency on whenjs. All the files are loaded (and in the correct order). but when is always undefined. I have absolutely no idea what I'm doing wrong. I've tried all sorts of ways to solve it. I also have a bower.json file if this helps anyone replicate the problem. Thanks in advance.

编辑:。然而,当js支持它时。

Autobahnjs does not currently support AMD. Whenjs, however, does support it.

推荐答案

现在已经

这篇关于在requirejs中正确加载依赖项(autobahn和whenjs)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 00:21