ionic3日历插件Calendar的使用

ionic3,可以使用Calendar插件,打开日历,并进行日程表的操作
官网https://ionicframework.com/docs/native/calendar/

安装插件

ionic cordova plugin add cordova-plugin-calendar
npm install --save @ionic-native/calendar
*在app.module.ts中引入calendar
*index.html中引入Calendar.js
<script type="text/javascript" src="js/Calendar.js"></script>

代码实现

html编码

<ion-content>
    <h2>Calendar</h2>
  <button (click)="getcalender()" ion-button full>calender</button>
</ion-content>
ts编码
引入import { Calendar } from '@ionic-native/calendar';

构造
constructor(public navCtrl: NavController,
              private calendar : Calendar) {
  }
 //创建并打开
getcalender(){
    
    this.calendar.createCalendar('MyCalendar').then(
      (msg) => { console.log(msg);},
      (err) => { console.log(err);}
    );

    this.calendar.openCalendar(new Date()).then(
      (msg) => { console.log(msg);},
      (err) => { console.log(err);}
    );
  }
根据官网示例的代码,只能创建日历,如果不执行openCalendar()方法,并不会看到你创建的日历。
有关日程的操作可参照官网API.



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值