javascript Traceur 运行时:超级表达式必须为空或函数,而不是未定义
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28551582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Traceur runtime: Super expression must either be null or a function, not undefined
提问by styler
Learning ES6 and have run in to the following error straight off Super expression must either be null or a function, not undefined.
Really unsure where my problem is, if anyone could help that would be great.
学习 ES6 并直接遇到以下错误Super expression must either be null or a function, not undefined.
真的不确定我的问题出在哪里,如果有人能提供帮助那就太好了。
main.js
主文件
'use strict'
import Backbone from 'exoskeleton';
import App from './views/App';
var onDOMReady = () => {
console.log('inside dom ready');
window.app = new App();
}
if(document.readyState === 'complete' || document.readyState === 'interactive' || document.readyState === 'loaded' ) {
onDOMReady();
} else {
document.addEventListener('DOMContentLoaded', onDOMReady);
}
App.js
应用程序.js
'use strict'
import Backbone from 'exoskeleton';
class App extends Backbone.View {
initialize () {
console.log('App: Init');
}
render () {
console.log('App: Render');
}
}
export default App;
回答by Lukas
I got this error because I had a circular import structure. One module importing another and the other way around.
我收到这个错误是因为我有一个循环导入结构。一个模块导入另一个模块,反之亦然。
回答by Lukas
Backbone.View
may be undefined in your case. The snippet that produces this error is this,
Backbone.View
在您的情况下可能未定义。产生这个错误的片段是这样的,
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
}
回答by Ally
The issue for me was because I had used
我的问题是因为我用过
import { EditForm } from '../EditForm'
instead of
代替
import EditForm from '../EditForm'
To make matters worse the error message was complaining about a completely unrelated component that hadn't been modified in weeks. Safe to say this one caused me some headaches. Just think back to what you recently modified and the error is likely there.
更糟糕的是,错误消息抱怨的是一个完全不相关的组件,几个星期都没有修改过。可以肯定地说,这让我有些头疼。回想一下您最近修改的内容,错误很可能就在那里。