【发布时间】:2017-09-15 23:19:43
【问题描述】:
我想扩展 MediaSource。我正在使用 Babel。
class BradMediaSource extends MediaSource {
constructor() {
super();
}
}
const source = new BradMediaSource();
直接在 Chrome 中,这工作正常。在使用 Babel 完成的编译构建中,我收到以下错误:
Uncaught TypeError: Failed to constructor 'MediaSource': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
这似乎类似于这个 GitHub 问题:https://github.com/babel/babel/issues/1966 我也尝试了以下包,但它似乎不适用于我的具体情况......没有区别:https://www.npmjs.com/package/babel-plugin-transform-custom-element-classes
我的.babelrc:
{ "presets": [ "es2015" ] }
有没有办法解决这个问题?
【问题讨论】:
标签: javascript ecmascript-6 babeljs es6-class