>普通操作用 回调函数 >promiss.service.ts 定义异步方法 ~~~ import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root' }) export class PromiseService { constructor() { } public getPromiseData(){ return new Promise((resolve,reject)=>{ setTimeout(()=>{ resolve({code:1,msg:"成功获取异步数据"}); },2000); }) } } ~~~ >demo.component.ts 使用promise进行调用 ~~~ public runPromise(): void { let a = this.PromiseService.getPromiseData(); a.then((data) => { console.log(data); }); } ~~~