Chào ae. Mình mới chuyển từ C# qua thằng Nodejs này thì thấy bỡ ngỡ quá. Nay mới mò ra thằng es6 có cải tiến thêm class làm cho node js hướng đối tượng hơn nhưng mình lại bị một lỗi như dưới:
VD1: code báo lỗi "taskCompleted is not defined"
class test {
taskCompleted(task) {
console.log("ok");
}
static ex() {
var http = new chilkat.Http();
var success;
success = http.UnlockComponent("Anything for 30-day trial");
var task = http.QuickGetAsync("http://www.wikipedia.org/");
task.Run(taskCompleted);
}
}
test.ex();
VD2: Code chạy ngon lành khi không dùng class
function taskCompleted(task) {
console.log("ok");
}
function ex() {
var http = new chilkat.Http();
var success;
success = http.UnlockComponent("Anything for 30-day trial");
var task = http.QuickGetAsync("http://www.wikipedia.org/");
task.Run(taskCompleted);
}
ex();
Cho mình hỏi là mình đang bị sai ở chỗ nào vậy. Đọc bao nhiêu tài liệu rồi mà không tìm ra cách xử lý vụ này mong ae giúp mình với. Cảm ơn