Angular TypeError:对象(…;)不是index.js上的函数

Angular TypeError:对象(…;)不是index.js上的函数,angular,ionic3,angular7,ionic4,Angular,Ionic3,Angular7,Ionic4,我是爱奥尼亚的新手, 我已将代码从angular 4.4更新为angular 7 这是包。json { "name": "mobile", "version": "0.0.0", "license": "MIT", "angular-cli": {}, "scripts": { "ng": "ng", "pree2e": "webdriver-manager update --standalone false --gecko false", "e2e"

我是爱奥尼亚的新手, 我已将代码从angular 4.4更新为angular 7

这是包。json

{
  "name": "mobile",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "7.1.1",
    "@angular/compiler": "7.1.1",
    "@angular/core": "^7.1.1",
    "@angular/forms": "7.1.1",
    "@angular/http": "^7.2.16",
    "@angular/platform-browser": "7.1.1",
    "@angular/platform-browser-dynamic": "7.1.1",
    "@angular/router": "7.1.1",
    "@auth0/angular-jwt": "^3.0.1",
    "@ionic-native/app-version": "^4.20.0",
    "@ionic-native/camera": "^4.20.0",
    "@ionic-native/core": "^5.21.6",
    "@ionic-native/crop": "^4.20.0",
    "@ionic-native/device": "^4.20.0",
    "@ionic-native/file": "^4.20.0",
    "@ionic-native/file-opener": "^4.20.0",
    "@ionic-native/image-resizer": "^4.20.0",
    "@ionic-native/network": "^4.20.0",
    "@ionic-native/push": "^4.20.0",
    "@ionic-native/screen-orientation": "^5.21.6",
    "@ionic-native/splash-screen": "^4.20.0",
    "@ionic-native/status-bar": "^5.21.6",
    "@ionic/storage": "^2.2.0",
    "@ngx-translate/core": "^12.1.1",
    "angular-oauth2-oidc-codeflow": "^4.0.1",
    "angular2-signaturepad": "^2.11.0",
    "angular2-virtual-scroll": "^0.4.16",
    "blob-util": "^2.0.2",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-support-google-services": "1.2.0",
    "core-js": "^3.6.4",
    "ionic-angular": "^3.8.0",
    "ionicons": "3.0.0",
    "ng2-img-cropper": "^0.9.0",
    "ng2-pica": "^1.2.12",
    "pouchdb": "^7.2.1",
    "pouchdb-adapter-cordova-sqlite": "^2.0.7",
    "pouchdb-find": "^7.2.1",
    "pouchdb-utils": "^7.2.1",
    "rxjs": "^6.5.4",
    "rxjs-compat": "^6.5.4",
    "rxjs-tslint": "^0.1.7",
    "ts-helpers": "^1.1.2",
    "zone.js": "^0.10.2"
  },
  "devDependencies": {
    "@angular/compiler-cli": "7.1.1",
    "@ionic-native/keyboard": "^5.21.6",
    "@ionic/app-scripts": "^3.1.11",
    "@types/jasmine": "3.5.7",
    "@types/node": "^13.7.4",
    "angular-cli": "1.0.0-beta.28.3",
    "angular2-moment": "^1.9.0",
    "codelyzer": "~5.2.1",
    "jasmine-core": "3.5.0",
    "jasmine-spec-reporter": "4.2.1",
    "karma": "4.4.1",
    "karma-chrome-launcher": "^3.1.0",
    "karma-cli": "^2.0.0",
    "karma-jasmine": "^3.1.1",
    "karma-remap-istanbul": "^0.6.0",
    "protractor": "~5.4.3",
    "ts-node": "8.6.2",
    "tslint": "^6.0.0",
    "typescript": "^3.7.5"
  },
  "cordova": {
    "plugins": {
      "cordova-plugin-file": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-app-version": {},
      "cordova-plugin-camera": {
        "CAMERA_USAGE_DESCRIPTION": "Take photo for user's avatar",
        "PHOTOLIBRARY_USAGE_DESCRIPTION": "Use photo for user's avatar"
      },
      "cordova-plugin-crop": {},
      "cordova-plugin-device": {},
      "cordova-plugin-file-opener2": {},
      "info.protonet.imageresizer": {},
      "phonegap-plugin-push": {
        "locator": "phonegap-plugin-push",
        "SENDER_ID": "70660752"
      },
      "cordova-plugin-network-information": {},
      "cordova-plugin-screen-orientation": {}
    }
  }
}
我删除了node\u模块package lock.json之后,我安装了npm来安装所有最新的依赖项

当我尝试运行项目时,它显示此错误对象(…)不是函数很难确定错误的确切位置

有人能帮我找出错误吗

提前感谢您

main.ts

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
import { AppModule } from './app/app.module';

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule);
index.html

<!DOCTYPE html>
<html lang="en" dir="ltr"  >
<head>
  <meta charset="UTF-8">
  <title>Detention Prevention</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <meta name="format-detection" content="telephone=no">
  <meta name="msapplication-tap-highlight" content="no">
  <link rel="icon" type="image/x-icon" href="assets/icon/favicon.ico">
  <link rel="manifest" href="manifest.json">
  <meta name="theme-color" content="#4e8ef7">

  <!-- The polyfills js is generated during the build process -->
  <!-- Pollyfills MUST BE before cordova : https://github.com/ionic-team/ionic-native/issues/505 -->
  <script src="build/polyfills.js"></script>

  <!-- cordova.js required for cordova apps -->
  <script src="cordova.js"></script>

  <!-- load custom JS -->
  <script src="custom-polyfills.js"></script>
  <script src="service-worker-loader.js"></script>

  <link href="build/main.css" rel="stylesheet">

</head>
<body class="background-under" >
  <!-- <ion-content class="page-account-type background-under no-bounce"> -->
    <img class="background-top" src="assets/img/bg-crop.jpg" alt="Login" width="100%" />
  <!-- Ionic's root component and where the app will load -->
  <ion-app></ion-app>

  <!-- The vendor js is generated during the build process
       It contains all of the dependencies in node_modules -->
  <script src="build/vendor.js"></script>

  <!-- The main bundle js is generated during the build process -->
  <script src="build/main.js"></script>

</body>
</html>

预防拘留

请检查相关性


也许它会帮助你解决这个问题

我也遇到了同样的问题,尽管我是按照医生说的做的。在删除插件和平台之后,我终于让它开始工作,然后遵循本教程。

祝你好运

在链接死亡的情况下进行编辑:

步骤1:启动新项目后或在现有项目目录中

$ ionic cordova plugin add cordova-plugin-nativestorage
$ npm install @ionic-native/native-storage
步骤2:添加到顶部的app.module.ts文件和提供程序中

import { NativeStorage } from '@ionic-native/native-storage/ngx';

providers: [
StatusBar,
SplashScreen,
NativeStorage,
步骤3:将其添加到要在ex:home.page.ts上使用的页面

import { Component } from '@angular/core';
import { NativeStorage } from '@ionic-native/native-storage/ngx';

@Component({
   selector: 'app-home',
   templateUrl: 'home.page.html',
   styleUrls: ['home.page.scss'],
})
export class HomePage {

constructor(
   private nativeStorage: NativeStorage
) {
}
步骤4:添加函数和测试

this.nativeStorage.setItem('freakyItem1', { property: 'value', anotherProperty: 'anotherValue' })
  .then(
    (data) => console.log('Stored first item!',data),
    error => console.error('Error storing item', error)
  );

我不知道为什么,但我以前尝试过所有这些,但都不起作用,但当我这样添加它时,效果很好。

你的main.ts是什么样子的?你能发布index.js文件吗?我已经发布了main.ts和index.htmlc。你能在回答中包含该链接的相关部分吗?如果那个链接断了,你的答案将失去它的价值。聪明,别想那个!