我做的事情:
安装了插件。在这里,我的应用程序/应用程序组件代码:
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]
我的关于 :
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);
}
我的网页 :
<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无法解析主题浏览器的所有参数:(?, ?, ?)。
2.打字稿错误 模块 '"/Users/apple/Desktop/ionic2-sidemenu-tabs-master/node_modules/ionic-native/dist/es5/index"' 没有导出的成员 'ThemeableBrowserObject'。 src/app/app.component.ts
此行 :import { ThemeableBrowser, ThemeableBrowserOptions, ThemeableBrowserObject } from 'ionic-native';
- 打字稿错误 模块 '"/Users/apple/Desktop/ionic2-sidemenu-tabs-master/node_modules/ionic-native/dist/es5/index"' 没有导出的成员 'ThemeableBrowserObject'。 src/app/app.module.ts
此行 :import { ThemeableBrowser, ThemeableBrowserOptions, ThemeableBrowserObject } from 'ionic-native';
- 打字稿错误 模块 '"/Users/apple/Desktop/ionic2-sidemenu-tabs-master/node_modules/ionic-native/dist/es5/index"' 没有导出的成员 'ThemeableBrowserObject'。 src/pages/about/about.ts
这一行:import { ThemeableBrowser, ThemeableBrowserOptions, ThemeableBrowserObject } from 'ionic-native';
- 打字稿错误 属性"create"在类型"类型主题浏览器"上不存在。 src/pages/about/about.ts
const browser: ThemeableBrowserObject = ThemeableBrowser.create('https://ionic.io', '_self', options);
此代码:
import { ThemeableBrowser } from 'ionic-native';
将给出导入错误
试试这个:
import { ThemeableBrowser } from '@ionic-native/themeable-browser';
我也遇到了这个问题。经过少量研究,我通过在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';
并编写代码。它会正常工作。