( 1 ) ionic 里的 angular 的版本
"@angular/animations": "5.2.11",
"@angular/common": "5.2.11",
"@angular/compiler": "5.2.11",
"@angular/compiler-cli": "5.2.11",
"@angular/core": "5.2.11",
"@angular/forms": "5.2.11",
"@angular/http": "5.2.11",
"@angular/platform-browser": "5.2.11",
"@angular/platform-browser-dynamic": "5.2.11",
( 2 ) home.ts 文件里的代码:
import { Component } from '@angular/core';
import {HttpClient} from '@angular/common/http';
@
Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(private httpService: HttpClient){
this.getRequestContact()
}
// 本地 json 文件请求
getRequestContact(){
this.httpService.get("assets/sqlite/user.json").subscribe(
res=>{
//成功
console.log(res)
},error=>{
//失败
console.error(error)
}
)
return this.httpService.get("assets/sqlite/user.json")
}
}