requirejs:模块名称“下划线”尚未加载上下文 [英] requirejs: Module name "underscore" has not been loaded yet for context
本文介绍了requirejs:模块名称“下划线”尚未加载上下文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我刚刚加载我的应用时,我总是收到此错误,
I always get this error when I freshly load my app,
Error: Module name "underscore" has not been loaded yet for context:
_. Use require([]) http://requirejs.org/docs/errors.html#notloaded
...,h){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.re...
require.js (line 8) TypeError: Backbone.Model is undefined
var ProjectModel = Backbone.Model.extend({
然后它们就消失了我点击浏览器上的刷新按钮。
But then they are gone when I hit the refresh button on my browser.
有谁知道为什么?我该如何解决?
Does anyone know why? How can I fix it?
这是我的config / main / entry js文件,
This is my config/ main/ entry js file,
require.config({
//By default load any module IDs from js/lib
baseUrl: 'js',
paths: {
jquery: 'lib/jquery/jquery-min',
underscore: 'lib/underscore/underscore-min',
backbone: 'lib/backbone/backbone-min',
text: 'lib/text/text'
},
shim: {
jquery: {
exports: '$'
},
underscore: {
exports: '_'
},
backbone: {
exports: 'Backbone'
}
}
});
require([
// Load our app module and pass it to our definition function
'app',
'jquery',
'underscore',
'backbone',
// Pull in the Collection module.
'collection/contacts'
], function(App){
// The "app" dependency is passed in as "App"
App.initialize();
});
我错过了什么吗?
< img src =https://i.stack.imgur.com/iKGgt.jpgalt =在此输入图像说明>
推荐答案
试试这个:
shim: {
jquery: {
exports: '$'
},
underscore: {
deps:["jquery"],
exports: '_'
},
backbone: {
deps:["jquery"],
exports: 'Backbone'
}
}
这篇关于requirejs:模块名称“下划线”尚未加载上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文