We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
babel会直接将箭头函数编译为普通函数,用到到this的地方会在箭头函数定义的作用域头部将this赋值给_this
编译箭头函数babel
@babel/plugin-transform-arrow-functions
示例
var a = (b) => b; const double = [1,2,3].map((num) => num * 2); var bob = { _name: "Bob", _friends: ["Sally", "Tom"], printFriends() { this._friends.forEach(f => console.log(this._name + " knows " + f)); } };
编译后
var a = function (b) { return b; }; const double = [1, 2, 3].map(function (num) { return num * 2; }); var bob = { _name: "Bob", _friends: ["Sally", "Tom"], printFriends() { var _this = this; this._friends.forEach(function (f) { return console.log(_this._name + " knows " + f); }); } };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
babel会直接将箭头函数编译为普通函数,用到到this的地方会在箭头函数定义的作用域头部将this赋值给_this
编译箭头函数babel
示例
编译后
The text was updated successfully, but these errors were encountered: