1、安裝 axios
cnpm install axios --save
2、用到的地方引入 axios
import axios from 'axios';
3創建angular服務 ng g service services/httpservice
在httpservice.service.ts引入 axios:並編寫方法axiosGet用於獲取后台相關的數據
在app.module.ts中引入該類HttpserviceService模塊
哪里需要就在哪里引入
HttpserviceService類import { HttpserviceService } from "../../services/httpservice.service";在組件news.component.ts constructor函數中聲明這樣組件就可以使用了
