Ionic 4 Camera / ActionSheet对象(...)不是一个功能 [英] Ionic 4 Camera/ActionSheet Object(...) is not a function
问题描述
我正在尝试在Ionic 4中使用Camera Plugin,当服务启动时没有错误,在浏览器控制台中出现此错误:
- 详细:
ionic:cli-framework:utils:process onBeforeExit handler:process.exit received + 0ms
ionic:cli-framework:utils:process onBeforeExit handler:running 1 queued functions + 6ms
ionic:cli-framework:utils:在处理8104的进程树时出现进程错误:{错误:命令失败:taskkill / pid 8104 / T / F错误:没有进行处理8104。在childProcess.exithandler(child_process.js:275:12)的emitTwo(events.js:126:13),在childProcess.emit(events.js:214:7)的maybeClose(internal / child_process.js:925:16)在Process.ChildProcess._handle.onexit(internal / child_process.js:209:5)kill:false,代码:128,signal:null,cmd:'taskkill / pid 8104 / T / F'} + 60ms
net.js:714
抛出新的TypeError(
^
出现此错误只有当一些TS文件具有导入时才会使用它。无论是否使用它都无关紧要。
导入{ActionSheet,ActionSheetOptions}来自'@ionic -native / action-sheet';
我已经解决了!
我需要安装@ 5.0.0-beta.14软件包。
npm i -s @ ionic-native / camera @ 5.0.0-beta.14
npm i -s @ ionic-native / action-sheet @ 5.0.0-beta.14
然后,我可以使用它:
从'@ ionic-native / camera / ngx'导入{Camera,CameraOptions};来自'@ ionic-native / action-sheet / ngx'的
import {ActionSheet,ActionSheetOptions};
I'm trying to use Camera Plugin in Ionic 4, and when the serve is started without errors, in the browser console appears this error:
I remove the folder node_modules and reinstall it, but can't fix this.
npm install
With ActionSheet I have the same error.
Dependencies in Package:
"dependencies": {
"@angular/common": "~6.1.1",
"@angular/core": "^6.1.2",
"@angular/forms": "~6.1.1",
"@angular/http": "~6.1.1",
"@angular/platform-browser": "^6.1.2",
"@angular/platform-browser-dynamic": "~6.1.1",
"@angular/router": "~6.1.1",
"@ionic-native/action-sheet": "^4.11.0",
"@ionic-native/camera": "^4.11.0",
"@ionic-native/core": "^5.0.0-beta.14",
"@ionic-native/file-transfer": "^4.11.0",
"@ionic-native/network": "^4.11.0",
"@ionic-native/splash-screen": "5.0.0-beta.14",
"@ionic-native/status-bar": "5.0.0-beta.14",
"@ionic/angular": "^4.0.0-beta.2",
"@ionic/lab": "^1.0.6",
"@ionic/ng-toolkit": "^1.0.6",
"@ionic/schematics-angular": "^1.0.0",
"cordova-android": "^7.1.1",
"cordova-android-support-gradle-release": "^1.4.4",
"cordova-ios": "4.5.5",
"cordova-plugin-actionsheet": "^2.3.3",
"cordova-plugin-camera": "^4.0.3",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-file": "^6.0.1",
"cordova-plugin-file-transfer": "^1.7.1",
"cordova-plugin-ionic-keyboard": "^2.1.2",
"cordova-plugin-ionic-webview": "^2.0.2",
"cordova-plugin-network-information": "^2.0.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-whitelist": "^1.3.3",
"core-js": "^2.5.3",
"promise-polyfill": "^8.0.0",
"rxjs": "^6.2.2",
"rxjs-compat": "^6.2.2",
"zone.js": "^0.8.26"
},
Thanks
EDIT: When I tried to compile it! (using ActionSheet)
--verbose:
ionic:cli-framework:utils:process onBeforeExit handler: process.exit received +0ms
ionic:cli-framework:utils:process onBeforeExit handler: running 1 queued functions +6ms
ionic:cli-framework:utils:process error while killing process tree for 8104: { Error: Command failed: taskkill /pid 8104 /T /F ERROR: no se encontr� el proceso "8104". at ChildProcess.exithandler (child_process.js:275:12) at emitTwo (events.js:126:13) at ChildProcess.emit (events.js:214:7) at maybeClose (internal/child_process.js:925:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) killed: false, code: 128, signal: null, cmd: 'taskkill /pid 8104 /T /F' } +60ms
net.js:714
throw new TypeError(
^
This error appears only if some TS file has the import. It does not matter if it is used.
import { ActionSheet, ActionSheetOptions } from '@ionic-native/action-sheet';
I have solved it!
I need to install @5.0.0-beta.14 packages.
npm i -s @ionic-native/camera@5.0.0-beta.14
npm i -s @ionic-native/action-sheet@5.0.0-beta.14
Then, I can use it with:
import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
import { ActionSheet, ActionSheetOptions } from '@ionic-native/action-sheet/ngx';
这篇关于Ionic 4 Camera / ActionSheet对象(...)不是一个功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!