ionic3 app 开发要点总结

web网址:http://zhengtu.siid.com.cn/

git地址:https://github.com/xif3681/job2-2-ionic3-zhengtu

  1. 开发坏境

Angular+Ionic+Cordova

开始步骤网站: http://ionicframework.com/getting-started/

官网css组件: http://ionicframework.com/docs/components/#header

1 安装IonicCordova

官网 http://ionicframework.com/

国内 http://www.ionic.wang/

命令行安装ionic

$ npm install -g cordova ionic

2 新建一个Ionic项目

$ ionic start myApp sidemenu

运行我们刚才创建的Ionic项目

$ cd myApp

$ionic cordova build browser

$ ionic platform add android

$ ionic build android

4 在浏览器预览并实时刷新

$ ionic serve

  1. 路由

默认

https://ionicframework.com/docs/api/navigation/IonicPage/

Dynamic Links

The segment property is useful for creating dynamic links. Sometimes the URL isn't known ahead of time, so it can be passed as a variable.

Since passing data around is common practice in an app, it can be reflected in the app's URL by using the :param syntax. For example, set the segment in the @IonicPage decorator:

@IonicPage({

  name: 'detail-page',

  segment: 'detail/:id'

})

In this case, when we push to a new instance of 'detail-page', the value of id will in the detailInfo data being passed to push will replace :id in the URL.

For example, to push the 'detail-page' in the ListPage component, the following code could be used:

@IonicPage({

  name: 'list'

})

export class ListPage {

  constructor(public navCtrl: NavController) {}

  pushPage(detailInfo) {

    // Push an `id` to the `'detail-page'`

    this.navCtrl.push('detail-page', {

      'id': detailInfo.id

    })

  }

}

If the value of detailInfo.id is 12, for example, the URL would end up looking like this:

http://localhost:8101/#/list/detail/12

  1. ionic3代理设置

Ionic-Cli代理设置:

打开ionic.config.json文件,添加proxies代理配置字段:

.手势

https://ionicframework.com/docs/components/#gestures

.锚点

1 点击导航到相应的锚点

Home.ts

Home.html

2 根据滚动条的位置自动更新对应的导航

.滑动导航

1 引入插件swiper

Index.html

2 初始配置

Home.ts

Home.html

Home.sass

.翻页

https://ionicframework.com/docs/components/#slides

Usage

List.ts

List.html

. 页面间数据传递

https://ionicframework.com/docs/api/util/Events/

Usage

import { Events } from 'ionic-angular';

// first page (publish an event when a user is created)

constructor(public events: Events) {}

createUser(user) {

  console.log('User created!')

  this.events.publish('user:created', user, Date.now());

}

// second page (listen for the user created event after function is called)

constructor(public events: Events) {

  events.subscribe('user:created', (user, time) => {

    // user and time are the same arguments passed in `events.publish(user, time)`

    console.log('Welcome', user, 'at', time);

  });

}

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值