平台 Platform

platform 的 API

Angular CDK platform API 参考文档

import {PlatformModule} from '@angular/cdk/platform';

本服务通过比较 userAgent 字符串和检查浏览器特定的全局属性来检测当前平台。

Service to detect the current platform by comparing the userAgent strings and checking browser-specific global properties.

属性
名称 描述

ANDROID: boolean

当前的平台是不是 Android 版。

Whether the current platform is Android.

BLINK: boolean

当前的渲染引擎是否为 Blink。

Whether the current rendering engine is Blink.

EDGE: boolean

当前的浏览器是否为 Microsoft Edge。

Whether the current browser is Microsoft Edge.

FIREFOX: boolean

当前的浏览器是否为 Firefox。

Whether the current browser is Firefox.

IOS: boolean

目前的平台是否为 Apple iOS。

Whether the current platform is Apple iOS.

SAFARI: boolean

当前的浏览器是否为 Safari。

Whether the current browser is Safari.

TRIDENT: boolean

当前的渲染引擎是否为 Microsoft Trident。

Whether the current rendering engine is Microsoft Trident.

WEBKIT: boolean

当前的渲染引擎是否为 WebKit。

Whether the current rendering engine is WebKit.

isBrowser: boolean

Angular 应用是否正在浏览器中渲染。

Whether the Angular application is being rendered in the browser.

getSupportedInputTypes

该浏览器支持的输入类型。

@returns The input types supported by this browser.

返回值

Returns

Set<string>

该浏览器支持的输入类型。

The input types supported by this browser.

supportsPassiveEventListeners

检查用户的浏览器是否支持被动事件侦听器。参见:https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md

Checks whether the user's browser supports passive event listeners. See: https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md

返回值

Returns

boolean
normalizePassiveListenerOptions

将 AddEventListener 对象规范化为可以在任何浏览器中传给 addEventListener 的,无论其是否支持 options 参数。

Normalizes an AddEventListener object to something that can be passed to addEventListener on any browser, no matter whether it supports the options parameter.

要规范化的对象。

@param options Object to be normalized.

参数

Parameters

options

AddEventListenerOptions

返回值

Returns

AddEventListenerOptions | boolean
supportsScrollBehavior

检查浏览器是否支持滚动行为。

Check whether the browser supports scroll behaviors.

返回值

Returns

boolean
getRtlScrollAxisType

检查此浏览器使用的 RTL 滚动轴的类型。在撰写本文时,Chrome 浏览器为 NORMAL(正常),Firefox 和 Safari 为 NEGATED(否),而 IE&Edge 为 INVERTED(反向)。

Checks the type of RTL scroll axis used by this browser. As of time of writing, Chrome is NORMAL, Firefox & Safari are NEGATED, and IE & Edge are INVERTED.

返回值

Returns

RtlScrollAxisType