ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] ## 概述 导出 ``` export interface StringValidator { isAcceptable(s: string): boolean; } export const test_name:string="test_name" ``` 导入 ``` import {test_name, StringValidator} from "./Validation"; ``` ## 导出重命名 ``` const test_name:string="test_name" export {test_name as name} //导入 import {name} from "./Validation"; ``` ## 导入重命名 `import {name as name2} from "./Validation";` ## 导入整个模块给一个变量 ``` import * as validator from "./ZipCodeValidator"; let myValidator = new validator.ZipCodeValidator(); ``` ## default 默认导出(不需要大括号) ``` //导出 let test_name:string="test_name" export default test_name //导入 import test_name from "./Validation" console.log(test_name); ```