未捕获的错误:不匹配的匿名定义()模块:函数定义(名称,全局) [英] Uncaught Error: Mismatched anonymous define() module: function definition(name, global)

查看:14
本文介绍了未捕获的错误:不匹配的匿名定义()模块:函数定义(名称,全局)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在加载主干的 requirejs 文件时遇到此错误.我尝试加载 r.js,requirejs 优化器,但我仍然坚持使用它.

I got this error while loading the requirejs file for the backbone. I tried loading the r.js, the requirejs optimizer, but I'm still stuck with it.

Uncaught Error: Mismatched anonymous define() module: function definition(name, global){

"use strict";

var PubSub = {
        name: 'PubSubJS',
        version: '1.3.1-dev'

以下是我的js:

define([
'jquery',
'underscore',
'backbone'
],function(){
subAccountRouter = Backbone.Router.extend({
  routes: {
  // Defining the routes
    'sub-accounts': 'subAccountList',
    '*actions': 'defaultAction'
  },
});

似乎对 requirejsdefine() 调用函数进行了一些更改,不知何故无法弄清楚.有人有想法吗??

Seems there have been some changes made to requirejs define() call function, somehow cant figure it out. Does anyone have ideas??

::

下面是 router.js 文件.

Below is the router.js file.

    define([
       'jquery',
       'underscore',
       'backbone'
      ],function($, _, Backbone){
          SubAccountRouter = Backbone.Router.extend({
              routes: {
               'sub-accounts': 'subAccountList',
               '*actions': 'defaultAction'
              },


           initialize: function () {
              this.appContainer = $("#subaccount");
    //collections and models
              this.subAccountCollection = null;
            this.subAccountModel = null;
          },

      subAccountList: function(){
        var self = this;
        },
     defaultAction: function(){
        this.subAccountList();
      },
      });

    return {
       initialize: function() {
           Backbone.history.start();

          }
        };
     }); //main func

我在这里做错了什么??我检查了我的所有路径,它们似乎是正确的,我仍然不明白为什么这个问题仍然困扰着我..:(我尝试更改路由的路径,并将参数传递给 function($, _, Backbone)(如下面的 sol'n 中的 1 所示).但是我似乎仍然看到错误.有没有人有其他想法???

What im i doing wrong here?? I check al my paths and they seem to be correct, i still dont get why this issue is still bugging me..:( I have tried changing the paths for the routes, and also passing arguments to the function($, _, Backbone)(as shown below in 1 of the sol'n). However i still seem to see the error. Does any one have any other ideas???

推荐答案

UPDATE

检查文档后 - 这实际上是他们讨论的第一个错误:

After checking the docs - this is actually the first error they discuss:

如果您在 HTML 中手动编写脚本标记以使用匿名define() 调用加载脚本,则可能会发生此错误."

"If you manually code a script tag in HTML to load a script with an anonymous define() call, this error can occur."

因此,请确保 index.html 中唯一的

相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆