输入
var o = { a, b, c };
输出
var o = { a: a, b: b, c: c };
输入
var cat = {
getName() {
return name;
}
};
输出
var cat = {
getName: function () {
return name;
}
};
npm install --save-dev babel-plugin-transform-es2015-shorthand-properties
.babelrc
(推荐).babelrc
{
"plugins": ["transform-es2015-shorthand-properties"]
}
babel --plugins transform-es2015-shorthand-properties script.js
require("babel-core").transform("code", {
plugins: ["transform-es2015-shorthand-properties"]
});