转换-内置-扩展似乎不起作用
transform-builtin-extend seems does not working
我有一个错误的翻译类:
Uncaught TypeError: Failed to construct 'FormData': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
at Form.ExtendableBuiltin (http://local.yandex.ru:30002/bundle.js:79395:14)
at new Form (http://local.yandex.ru:30002/bundle.js:79422:103)
我.babelrc :
{
"presets": ["react", "latest"],
"plugins": [
"babel-plugin-syntax-decorators",
"babel-plugin-transform-decorators-legacy",
["babel-plugin-transform-builtin-extend", { // Class Extending Natives
globals: ["FormData"],
approximate: true
}],
"transform-es2015-arrow-functions",
// "syntax-async-functions",
// "transform-async-to-generator",
// "transform-regenerator",
"transform-object-rest-spread",
"transform-rebem-jsx",
"transform-es2015-typeof-symbol"
],
}
我的类:
import map from 'lodash/map'
export default class Form extends FormData {
constructor (data) {
super()
map(data, (val, key) => this.append(key, val))
}
}
一段编译代码:
function _extendableBuiltin(cls) {
function ExtendableBuiltin() {
cls.apply(this, arguments);
}
式中cls
为FormData
。
期待这样的事情:
function _extendableBuiltin(cls) {
return function ExtendableBuiltin() {
return new cls(arguments);
}
巴别塔——版本6.14.0 (babel-core 6.14.0)
webpack——版本版本号:webpack 1.13.2
我做错了什么?
必须将approximate
选项设置为false
。从GitHub插件库:
在不支持重新分配现有对象原型的旧浏览器上,您将需要启用近似模式,这将回到Babel 5行为,使用简单的ES5继承来扩展
approximate
类,尽管您的结果可能取决于您的目标。
相关文章:
- o数据扩展查询在SystemUserRolesSet上不起作用
- 正在处理在chrome扩展中不起作用的js
- 为什么这个扩展方法不起作用
- 为什么我的谷歌浏览器扩展程序在谷歌浏览器版本 41.0.2272.89 中不起作用
- Chrome 扩展程序权限不起作用
- Chrome 扩展 cookies.getAll 不起作用
- List.JS 在通过 Chrome 扩展程序注入时不起作用
- 设置Sails js视图扩展不'不起作用
- 使用jQuery的Chrome扩展不起作用
- chrome扩展名“sendResponse”不起作用
- 基本的谷歌chrome扩展消息传递不起作用
- $(document).click()在chrome扩展中不起作用
- Javascript在Google Chrome扩展的选项页中不起作用
- 在chrome扩展的弹出窗口中,警报不起作用
- firefox扩展对$.ajax的调用不起作用
- I'我试图制作一个chrome查找和替换扩展,但它赢了;不起作用
- chrome扩展弹出相同的选项卡仍然不起作用
- Javascript按钮单击在Chrome扩展弹出窗口中不起作用
- Google Chrome扩展:setAttribute没有'不起作用
- 验证不起作用(扩展)