Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ionic 3 angular本机屏幕截图因typeError失败_Angular_Ionic3 - Fatal编程技术网

ionic 3 angular本机屏幕截图因typeError失败

ionic 3 angular本机屏幕截图因typeError失败,angular,ionic3,Angular,Ionic3,我正在使用 我的代码如下所示: 应用程序模块.ts import { Screenshot } from '@ionic-native/screenshot'; providers: [ StatusBar, ThemeProvider, OpportunityService, Screenshot, {provide: ErrorHandler, useClass: IonicErrorHandler} ] }) export class AppM

我正在使用

我的代码如下所示:

应用程序模块.ts

import { Screenshot } from '@ionic-native/screenshot';

providers: [
    StatusBar,
    ThemeProvider,
    OpportunityService,
    Screenshot,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}
 constructor(public navCtrl: NavController,
              public screenshot: Screenshot) {
                this.showRow = false;
  }

getFeedback(){
       // this.screenshot.save('jpg', 100,'vik.jpg')
       this.screenshot.save('jpg', 80, 'myscreenshot.jpg').then(
            () => alert('got it'),
            (err) => console.log(err)
        );
   }
}
home.ts

import { Screenshot } from '@ionic-native/screenshot';

providers: [
    StatusBar,
    ThemeProvider,
    OpportunityService,
    Screenshot,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}
 constructor(public navCtrl: NavController,
              public screenshot: Screenshot) {
                this.showRow = false;
  }

getFeedback(){
       // this.screenshot.save('jpg', 100,'vik.jpg')
       this.screenshot.save('jpg', 80, 'myscreenshot.jpg').then(
            () => alert('got it'),
            (err) => console.log(err)
        );
   }
}
但我看到了错误:

TypeError: Cannot read property 'save' of undefined
    at index.js:54
    at new t (polyfills.js:3)
    at Screenshot.save (index.js:53)
    at 

您已将其导入app.module.ts,但是否已将屏幕截图导入home.ts

import { Screenshot } from '@ionic-native/screenshot';

在较新的版本中,ionic 4+

import { Screenshot } from '@ionic-native/screenshot/ngx';

注意:这将在真正的设备上工作,而不是在离子服务上。

我觉得它很合适。也许其他人可以帮忙。