关于ionic实现显示日期的功能

首先展示结果图:

选中某一天的样式 

使用步骤:

第一步:在项目中安装ionic3-calendar-en,安装代码:

npm install ionic3-calendar-en --save

第二步:在app.module.ts中添加

import { CalendarModule } from 'ionic3-calendar-en';

以及在imports中添加 CalendarModule

imports: [
        BrowserModule,
        CalendarModule,
        IonicModule.forRoot(MyApp)
    ],

第三步:在自己需要显示的HTML页面以及位置添加代码:

<ion-calendar #calendar  (onDaySelect)="onDaySelect($event)"></ion-calendar>

在ts页面使用这个方法来判断点击的是哪一个日期:

onDaySelect($event){
        console.log($event);
    }

这样基础的一个月的日期就可以显示出来了

ps:关于我修改周显示文字以及样式:

修改周文字,代码如下:(我是用position把要显示的周文字覆盖在了日历的周上面,week中是需要显示的东西)

html页面:
<div style="top: 30px;position: absolute;width: 100%;">
        <ion-grid>
            <ion-row>
                <ion-col *ngFor="let x of week" style="width: 14.25%;position: relative;padding: 0.8rem;text-align: center;">
                    {{x}}
                </ion-col>
            </ion-row>
        </ion-grid>
    </div>


ts页面定义:
week: any = ['日','一','二','三','四','五','六'];

修改样式代码如下:(主要是在网页上面选择查看需要修改的是具体哪个样式的)

scss代码:

ion-calendar .calendar-row .calendar-col {
        border: 0px;
    }

    ion-calendar .calendar-row .today {
        color: black;
        box-shadow: none;
        background: white;
    }

    ion-calendar .calendar-row .select {
        box-shadow: none;
        color: #fff;
        background: #2B7D62;
    }

    .grid {
        padding: 0px;
    }

    ion-calendar .calendar-header-col {
        color: white;
        height: 0px;
        padding: 0px;
    }

    .row[justify-content-center] {
        margin-bottom: 30px;
        height: 30px;
    }

其他的一些显示参考链接:

https://www.npmjs.com/package/ionic3-calendar

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Ionic实现图片预览可以使用 Ionicion-slides 组件和 ngx-gallery 库。 1. 首先,在终端中运行以下命令安装 ngx-gallery 库: ``` npm install @kolkov/ngx-gallery --save ``` 2. 在 app.module.ts 中导入 NgxGalleryModule: ```typescript import { NgxGalleryModule } from '@kolkov/ngx-gallery'; @NgModule({ imports: [ // ... NgxGalleryModule ], // ... }) export class AppModule { } ``` 3. 在 HTML 中使用 ion-slides 组件,并在其中使用 ngx-gallery: ```html <ion-slides pager="true"> <ion-slide *ngFor="let image of images"> <ngx-gallery [options]="galleryOptions" [images]="[image]"></ngx-gallery> </ion-slide> </ion-slides> ``` 4. 在 TypeScript 文件中定义图片和 ngx-gallery 的选项: ```typescript import { Component } from '@angular/core'; @Component({ selector: 'app-home', templateUrl: 'home.page.html', styleUrls: ['home.page.scss'], }) export class HomePage { images = [ { small: 'https://picsum.photos/id/1018/200/300', medium: 'https://picsum.photos/id/1018/500/750', big: 'https://picsum.photos/id/1018/1200/1800', description: 'Image 1' }, { small: 'https://picsum.photos/id/1015/200/300', medium: 'https://picsum.photos/id/1015/500/750', big: 'https://picsum.photos/id/1015/1200/1800', description: 'Image 2' }, { small: 'https://picsum.photos/id/1019/200/300', medium: 'https://picsum.photos/id/1019/500/750', big: 'https://picsum.photos/id/1019/1200/1800', description: 'Image 3' } ]; galleryOptions = [ { width: '100%', height: 'auto', thumbnailsColumns: 4, imageAnimation: 'slide', preview: false } ]; constructor() {} } ``` 这样,就可以在 Ionic实现图片预览了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值