backbone.js - backbone.js: Right-hand side of 'instanceof' is not an object
问题描述
I'm newer with jquery and backbone, hope someone could help me with this error. I have a web application that, sometimes, throws this error in the console
require.js:900 TypeError: Right-hand side of 'instanceof' is not an object at child.setElement (backbone.js?__nc__=1527837925799:1040) at child._ensureElement (backbone.js?__nc__=1527837925799:1102) at child.Backbone.View (backbone.js?__nc__=1527837925799:990) at child [as constructor] (backbone.js?__nc__=1527837925799:1545) at new child (backbone.js?__nc__=1527837925799:1545) at child.initialize (application.js?__nc__=1527837925799:357) at child.Inditex.Application (backbone-inditex-1.2.0.js?__nc__=1527837925799:27) at new child (backbone.js?__nc__=1527837925799:1545) at createApp (main.js:201)
at Object.execCb (require.js:1690)
If this error happens, with a reload of the webpage is fixed (sometimes with 3 or 4 times) but I can't know why this happens.
I have found the line where this error is thrown. In backbone.js file, the method setElement
setElement: function(element, delegate) { debugger; if (this.$el) this.undelegateEvents(); this.$el = element instanceof Backbone.$ ? element : Backbone.$(element); this.el = this.$el[0]; if (delegate !== false) this.delegateEvents(); return this; },
sometimes, Backbone.$ is not an object and is when the error hapens.
¿Any idea for resolving this error? I'm using backbone.js 1.1.0
Thanks in advance
解决方案
就我而言,我可以修复它更改我的 main.js。错误是,在某些情况下,在加载 jquery 之前加载了主干。我的 main.js 是这样的
垫片:{'underscore':{出口:'_'},'backbone':{deps:['underscore'],出口:'Backbone'}
我必须在 jquery 的主干中添加一个 deps,就像这样
垫片:{'underscore':{出口:'_'},'backbone':{deps:['jquery','underscore'],出口:'Backbone'}
推荐阅读
- lwjgl - GLFW 中的平滑触摸板滚动
- php - 用于教育目的的小型 PHP 运行时(解释器)
- javascript - jQuery重构,如何为此制作简单的短代码
- postgresql - 如何处理 Kafka 中的动态消息值?
- pandas - 如何根据其他两列的值设置列?
- excel - 根据数量将复制整行更改为复制范围
- python - 烧瓶中的 Exception.TemplateSyntaxError
- java - 如何按列和行在for循环中添加到矩形数组
- angular - 如何使用按钮将 JSON 数据复制到剪贴板
- objective-c - 知道何时从 Xamarin 抛出 NSException