6
Ai đó có thể giúp tôi xin vui lòngKhông thể xuất liên tục trong nguyên cảo
Tôi có 2 file main.ts và hi.ts
hi.ts:
export const hello = "dd";
main.ts:
import { hello } from "./hi";
...
class A {
public sayHello() {
console.log("hello=" + hello);
}
...
}
Tôi có ngoại lệ:
Uncaught ReferenceError: hello is not defined(…)
Làm cách nào tôi có thể thấy biến const này từ lớp A? Có thể không?
Xem câu hỏi này: http://stackoverflow.com/questions/32647215/declaring-static-constants-in-es6-classes – twicejr
Tôi làm xuất const hello = "dd"; như trong liên kết của bạn nhưng nó không hoạt động – EgorTitov
Trong Node.js hoặc trong trình duyệt? – Paleo