2013-03-16 74 views
2

我有一些問題試圖讓我的Phonegap應用程序在使用r.js後使用RequireJS,BackboneJS和各種庫進行工作。我得到我的主build.js以下錯誤優化事後但是之前未捕獲TypeError:無法讀取undefined RequireJS Optimizer Backbone的屬性'View'

Uncaught TypeError: Cannot read property 'View'

下面是我需要配置

require.config({ 
baseUrl: 'lib', 
paths: { 
    domReady  : 'require/domReady', 
    text   : 'require/text', 
    async   : 'require/async', 
    jquery   : 'jquery/jquery', 
    jqmconfig  : 'jqm/jqm-config', 
    jqm    : 'jqm/jquery.mobile', 
    underscore  : 'underscore/underscore', 
    backbone  : 'backbone/backbone', 
    jqmaps   : 'google/jquery.ui.map', 
    router   : '../app/router', 
    models   : '../app/models', 
    collections  : '../app/collections', 
    views   : '../app/views', 
    templates  : '../app/templates', 
    app    : '../app/app' 
}, 
shim: { 
    underscore: { 
     exports  : '_' 
    }, 
    backbone: { 
     deps   : ['jquery', 'jqmconfig', 'jqm', 'underscore'], 
     exports  : 'Backbone' 
    }, 
    jqmconfig   : ['jquery'], 
    jqm    : ['jquery','jqmconfig'], 
    jqmaps   : ['jqm'] 
}}); 

一切正常,這是我的引導

require(
[ 
    'app', 'domReady', 'jqmconfig' 
], 

function(app, domReady){ 

    domReady(function() { 
     // On device ready initialize the app code 
    }); 
}); 

這裏是我的build.js

({ 
baseUrl: 'lib', 
paths: { 
    domReady  : 'require/domReady', 
    text   : 'require/text', 
    async   : 'require/async', 
    jquery   : 'jquery/jquery', 
    jqmconfig  : 'jqm/jqm-config', 
    jqm    : 'jqm/jquery.mobile', 
    underscore  : 'underscore/underscore', 
    backbone  : 'backbone/backbone', 
    jqmaps   : 'google/jquery.ui.map', 
    router   : '../app/router', 
    models   : '../app/models', 
    collections  : '../app/collections', 
    views   : '../app/views', 
    templates  : '../app/templates', 
    app    : '../app/app', 
    main   : '../app/main', 
}, 
name: 'main', 
out: 'app/main-build.js'}) 

什麼東西顯而易見?

謝謝你的時間。

回答

1

shim-config應該在build.js文件中公佈,所以r.js可以正確包含填充依賴項到app/main-build.js。您可以簡單地在build.js中複製您的墊片或更好地指定mainConfigFile選項,以便您的pathsshim只能在一個位置列出。

+0

非常感謝! – 2013-03-17 08:57:26

+0

歡迎您:) – user20140268 2013-03-17 10:51:28

相關問題