【angular2】@angula/cdk/platform 学习03

1. cdk 文档 https://material.angular.io/cdk/categories

2. platform 模块提供获取平台信息,以及平台支持的功能

(1)在使用之前的先import PlatformModule模块到我们工程里面来(这也是使用cdk里面Platform里面功能的前提),比如咱们可以在app.module.ts文件里面引入。引入方式如下:

  • import { PlatformModule } from '@angular/cdk/platform';
    
    @NgModule({
        ...
        imports: [
            ...,
            PlatformModule,
            ...
        ],
        ...
    })
    export class AppModule {
    }

(2)有一个 Service

Platform 类,用法也是非常的简单,就一些属性的使用。属性解释如下:

  • Platform类属性类型解释
    ANDROID boolean 当前平台是否android系统
    IOS boolean 当前平台是否IOS系统
    isBrowser boolean 当前平台是否浏览器
    EDGE boolean 当前平台是否edge浏览器
    FIREFOX boolean 当前平台是否firefox浏览器
    SAFARI boolean 当前平台是否safari浏览器
    TRIDENT boolean 当前平台浏览器的render engine是否为Microsoft Trident
    WEBKIT boolean 当前平台浏览器的render engine是否为Webkit
    BLINK boolean 当前平台浏览器的render engine是否为Blink

(3)提供的功能点

功能点Platform模块方法参数返回值解释
01 getSupportedInputTypes Set 当前浏览器支持的输入类型(比如 text, date, number, tel 等)
02 supportsPassiveEventListeners boolean 当前浏览器是否支持被动事件监听器
03 normalizePassiveListenerOptions AddEventListenerOptions AddEventListenerOptions 或者 boolean 兼容各种浏览器 AddEventListener 的 options 处理
04 supportsScrollBehavior boolean 当前浏览器是否支持滑动行为
05 getRtlScrollAxisType RtlScrollAxisType

获取当前浏览器使用的RTL滚动轴的类型(export const enum RtlScrollAxisType

Chrome的是NORMAL, Firefox和 Safari的是NEGATED, IE和Edge的是INVERTED.)

06 _supportsShadowDom boolean 当前浏览器是否支持 ShadowDom
07 _getShadowRoot element: HTMLElement ShadowRoot | null 获取 元素element 的 ShadowDom

 

posted @ 2021-02-19 15:05  耶梦加德  阅读(43)  评论(0编辑  收藏  举报