下面代码分别是源码,TSC+ES6编译出来的代码,Creator3.0编译出来的结果。
不良后果是在Creator3.0的lambda里面this不能悬停,报undefined。TSC的可以悬停,工作良好。
=============源码
class EEE
{
private num = 888;
start () {
debugger;
console.log(1, this.num);
let bbb = ()=>{
console.log(2, this.num);
let ccc = ()=>{
console.log(3, this.num);
};
ccc();
}
bbb();
}
}
new EEE().start();
==============TSC + ES6编译出来的
class EEE {
constructor() {
this.num = 888;
}
start() {
debugger;
console.log(1, this.num);
let bbb = () => {
console.log(2, this.num);
let ccc = () => {
console.log(3, this.num);
};
ccc();
};
bbb();
}
}
new EEE().start();
=====================Creator 3.0编译出来的
_proto.start = function start() {
var _this2 = this;
debugger;
console.log(1, this.num);
var bbb = function bbb() {
console.log(2, _this2.num);
var ccc = function ccc() {
console.log(3, _this2.num);
};
ccc();
};
bbb();
};