Nei*_*oFR 1 module http ionic-framework angular
我正在尝试@ionic-native/http在Ionic 4应用程序中使用该模块。它是新的,正在尝试在home.page组件中使用它。但是我得到这个错误:
Uncaught Error: Unexpected value 'HTTP' imported by the module 'AppModule'. Please add a @NgModule annotation.
我尝试了很多事情,甚至使用@beta模块,也将import语句添加到app.module.ts了imports []数组中。
她是app.module.ts
...
import { HTTP } from '@ionic-native/http/ngx';
...
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule, HTTP],
...Run Code Online (Sandbox Code Playgroud)
这是home.page.ts文件
...
import { HTTP } from '@ionic-native/http/ngx';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
constructor(private http: HTTP) {}
....
}Run Code Online (Sandbox Code Playgroud)
我想念什么?
大家晚上好。
HTTP不是一个模块。您必须将其放在应用程序模块提供程序数组下。
...
import { HTTP } from '@ionic-native/http/ngx';
...
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
providers: [HTTP]
...
Run Code Online (Sandbox Code Playgroud)
供参考:https : //ionicframework.com/docs/native/#Add_Plugins_to_Your_App_Module
| 归档时间: |
|
| 查看次数: |
3357 次 |
| 最近记录: |