我做的事情:
安装了该插件。我这里是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]
我的约.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);
}
我的HTML:
<button ion-button icon-only (click)="open()">
<ion-icon>OPEN PDF</ion-icon>
</button>
所以我不知道,我做错了什么。我收到很多错误:
1。找不到模块Cannot find module "@ionic-native/core"
请帮帮我。我在代码中做错了什么......
提前致谢!!
错误:
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.
我的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"
}
错误:
1 无法解析ThemeableBrowser的所有参数:(?,?,?)。
2. 打字稿错误 模块&#39;&#34; / Users / apple / Desktop / ionic2-sidemenu-tabs-master / node_modules / ionic-native / dist / es5 / index&#34;&#39;没有导出的成员&#39; ThemeableBrowserObject&#39;。 SRC /应用/ app.component.ts
这一行:import { ThemeableBrowser, ThemeableBrowserOptions, ThemeableBrowserObject } from 'ionic-native';
这一行:import { ThemeableBrowser, ThemeableBrowserOptions, ThemeableBrowserObject } from 'ionic-native';
这一行:import { ThemeableBrowser, ThemeableBrowserOptions, ThemeableBrowserObject } from 'ionic-native';
const browser: ThemeableBrowserObject = ThemeableBrowser.create('https://ionic.io', '_self', options);
答案 0 :(得分:0)
此代码:
import { ThemeableBrowser } from 'ionic-native';
会出现导入错误
请改为尝试:
import { ThemeableBrowser } from '@ionic-native/themeable-browser';
答案 1 :(得分:0)
我也遇到了这个问题。经过一些研究后,我通过在app.module.ts中导入“ ThemeableBrowser ”解决了这个问题,并将其添加为提供者,然后导入所有 {ThemeableBrowser,ThemeableBrowserOptions,ThemeableBrowserObject} 你需要的文件。
解决方案:
app.module.ts:
import { ThemeableBrowser } from '@ionic-native/themeable-browser';
和
providers: [
StatusBar,
SplashScreen,
ThemeableBrowser,
{ provide: ErrorHandler, useClass: IonicErrorHandler },
// as per your requirement
]
然后在app.component.ts(或任何其他文件)中:
import { ThemeableBrowser, ThemeableBrowserOptions, ThemeableBrowserObject } from '@ionic-native/themeable-browser';
并编写代码。它会正常工作。