【发布时间】:2019-07-19 11:30:26
【问题描述】:
我从 API 获得了一个角度模块的详细信息。该模块在 ES6 中 我想将该模块代码转换为 ES5 语法。
我在安装 babel 运行时后尝试了import { transform } from 'babel-core';。但它正在抛出错误。
load() {
fetch(url) // making the get request for loading the module response
.then(response => response.text())
.then(source => {
// i want to convert this response to es5 standard. right now it is in es6
});
}
我的期望是在 Angular 运行时将 es6 转换为 es5 代码 组件函数。
【问题讨论】:
-
为什么?如果您正确配置,打字稿编译器会为您执行此操作。见typescript configuration docs
-
@Liam 实际上响应是字符串形式的。我想转换那个字符串代码。对此有何建议?
-
“以字符串形式”是什么意思?
-
等待加载外部库然后运行它?这听起来像是等待发生的代码注入攻击
标签: javascript angular ecmascript-5 es5-compatiblity