Default export trong Typescript là gì? Tại sao sử dụng chúng?

{{FormatNumbertoThousand(model.total_like)}} lượt thích
2.597 lượt xem

Mỗi module có thể tùy chọn xuất default export và default export hoạt động với từ khóa mặc định và chúng ta chỉ có thể sử dụng một default export cho mỗi module.

export class User {

//Todo your logic here..

}

//And then -

import { User } from "./User"; //OR //BaseUrl.ts

export default "http://localhost:57431/Account/Login";

//Login.ts

import BaseUrl from "../BaseUrl";

console.log(BaseUrl);

//"http://localhost:57431/Account/Login"
Câu hỏi tiếp theo: Phân biệt Module và Namespace?
{{login.error}}