第一步: 安装ionic
npm install -g ionic
第二步: 使用Ionic创建一个Project:
ionic start myApp blank
第三步: 安装Plugin
In APP Browser
- cd myApp
- ionic cordova plugin add cordova-plugin-inappbrowser
- npm install –save @ionic-native/in-app-browser
HTTP Plugin
- ionic cordova plugin add cordova-plugin-advanced-http
- npm install –save @ionic-native/http
第四步: 修改代码, 重定向到你的网站
1 打开config.xml, 插入:
<access origin=”*” />
<allow-navigation href=”*” />
2. 打开”./src/app/app.module.ts”文件, 在最上边加上:
import { HTTP } from ‘@ionic-native/http’;
import { HttpClientModule } from ‘@angular/common/http’;
import { InAppBrowser } from ‘@ionic-native/in-app-browser’;
3. 在app.module.ts的下部, 找到providers, 加上:
providers: [
HTTP,
HttpClientModule,
InAppBrowser,
]
4. 打开”./src/pages/home/home.ts,
import { Component } from ‘@angular/core’;
import { NavController, Platform } from ‘ionic-angular’;
import { InAppBrowser } from ‘@ionic-native/in-app-browser’;
@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})
export class HomePage {
constructor(public navCtrl: NavController, public plt: Platform, public iab: InAppBrowser) {
this.plt.ready().then((readySource) => {
this.iab.create(‘https://ionicframework.com/’);
});
}
}
第五步, Build IOS
ionic cordova build ios
出现问题:
没有办法Scroll.