ionic 2 themeable browser error “”

时光怂恿深爱的人放手 提交于 2019-12-11 08:26:23

问题


Things i did :

installed the plugin. Ans here my code for app/app.component :

import { ThemeableBrowser, ThemeableBrowserOptions, ThemeableBrowserObject } from '@ionic-native/themeable-browser';

app/app.module.ts : import { ThemeableBrowser, ThemeableBrowserOptions, ThemeableBrowserObject } from '@ionic-native/themeable-browser';

providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}ThemeableBrowser]

My about.ts :

import { ThemeableBrowser } from 'ionic-native';

open() {

  const options: ThemeableBrowserOptions = {
        statusbar: {
            color: '#ffffffff'
        },
        toolbar: {
            height: 44,
            color: '#f0f0f0ff'
        },
        title: {
            color: '#003264ff',
            showPageTitle: true
        },
        backButton: {
            image: 'back',
            imagePressed: 'back_pressed',
            align: 'left',
            event: 'backPressed'
        },
        forwardButton: {
            image: 'forward',
            imagePressed: 'forward_pressed',
            align: 'left',
            event: 'forwardPressed'
        },
        closeButton: {
            image: 'close',
            imagePressed: 'close_pressed',
            align: 'left',
            event: 'closePressed'
        },
        customButtons: [
            {
                image: 'share',
                imagePressed: 'share_pressed',
                align: 'right',
                event: 'sharePressed'
            }
        ],
        menu: {
            image: 'menu',
            imagePressed: 'menu_pressed',
            title: 'Test',
            cancel: 'Cancel',
            align: 'right',
            items: [
                {
                    event: 'helloPressed',
                    label: 'Hello World!'
                },
                {
                    event: 'testPressed',
                    label: 'Test!'
                }
            ]
        },
        backButtonCanClose: true
    };

    const browser: ThemeableBrowserObject = this.themeableBrowser.create('https://ionic.io', '_self', options);

  }

My html :

<button ion-button icon-only (click)="open()">
        <ion-icon>OPEN PDF</ion-icon>
      </button>

So i don't know, what i am doing wrong. I am getting many error :

1. cannot find the module Cannot find module "@ionic-native/core"

please help me out. what i am doing wrong in my code...

Thanks in advance !!

error:

 ionic-hello-world@ /Users/apple/Desktop/ionic2-sidemenu-tabs-master
├── @ionic-native/core@3.7.0 
└── UNMET PEER DEPENDENCY rxjs@5.0.0-beta.12

npm WARN @ionic-native/themeable-browser@3.7.0 requires a peer of rxjs@^5.0.1 but none was installed.
npm WARN @ionic-native/core@3.7.0 requires a peer of rxjs@^5.0.1 but none was installed.

My package.json:

   "dependencies": {
        "@angular/common": "2.2.1",
        "@angular/compiler": "2.2.1",
        "@angular/compiler-cli": "2.2.1",
        "@angular/core": "2.2.1",
        "@angular/forms": "2.2.1",
        "@angular/http": "2.2.1",
        "@angular/platform-browser": "2.2.1",
        "@angular/platform-browser-dynamic": "2.2.1",
        "@angular/platform-server": "2.2.1",
        "@ionic-native/core": "^3.7.0",
        "@ionic-native/themeable-browser": "^3.7.0",
        "@ionic/storage": "1.1.7",
        "ionic-angular": "2.0.0",
        "ionic-native": "2.4.1",
        "ionicons": "3.0.0",
        "rxjs": "5.0.0-beta.12",
        "sw-toolbox": "3.4.0",
        "zone.js": "0.6.26"
}

update :

error:

1 Can't resolve all parameters for ThemeableBrowser: (?, ?, ?).

2.Typescript Error Module '"/Users/apple/Desktop/ionic2-sidemenu-tabs-master/node_modules/ionic-native/dist/es5/index"' has no exported member 'ThemeableBrowserObject'. src/app/app.component.ts

this line :import { ThemeableBrowser, ThemeableBrowserOptions, ThemeableBrowserObject } from 'ionic-native';

  1. Typescript Error Module '"/Users/apple/Desktop/ionic2-sidemenu-tabs-master/node_modules/ionic-native/dist/es5/index"' has no exported member 'ThemeableBrowserObject'. src/app/app.module.ts

this line : import { ThemeableBrowser, ThemeableBrowserOptions, ThemeableBrowserObject } from 'ionic-native';

  1. Typescript Error Module '"/Users/apple/Desktop/ionic2-sidemenu-tabs-master/node_modules/ionic-native/dist/es5/index"' has no exported member 'ThemeableBrowserObject'. src/pages/about/about.ts

this line: import { ThemeableBrowser, ThemeableBrowserOptions, ThemeableBrowserObject } from 'ionic-native';

  1. Typescript Error Property 'create' does not exist on type 'typeof ThemeableBrowser'. src/pages/about/about.ts

const browser: ThemeableBrowserObject = ThemeableBrowser.create('https://ionic.io', '_self', options);


回答1:


This code:

import { ThemeableBrowser } from 'ionic-native';

Will give an import error

Try this instead:

import { ThemeableBrowser } from '@ionic-native/themeable-browser';



回答2:


I also faced this problem. After little research I solved it by importing "ThemeableBrowser" in app.module.ts and add the same as provider and after that import all { ThemeableBrowser, ThemeableBrowserOptions, ThemeableBrowserObject} in your required file.

Solution:

app.module.ts:

import { ThemeableBrowser } from '@ionic-native/themeable-browser';

and

providers: [
    StatusBar,
    SplashScreen,
    ThemeableBrowser,
    { provide: ErrorHandler, useClass: IonicErrorHandler },
// as per your requirement
  ]

Then in app.component.ts (or any other file):

import { ThemeableBrowser, ThemeableBrowserOptions, ThemeableBrowserObject } from '@ionic-native/themeable-browser';

and write your code. It will work fine.



来源:https://stackoverflow.com/questions/43887323/ionic-2-themeable-browser-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!