export
:导出模块
point.ts 文件的内容(导出)
interface IPoint{ num:number printNum:() => void; } // 关键字 export 导出模块 export class Point implements IPoint{ constructor(public num:number){ this.num = num; } printNum= () => { console.log(this.num) }; }
import { 类 | 方法 | 变量 } from 'ts文件路径(不带后缀)'
app.ts 文件的内容(导入)
import {Point} from './point' const point = new Point(832) point.printNum()