Appearance
现代浏览器
¥Modern-browsers
用于定义现代 JavaScript 客户端和旧版 JavaScript 客户端之间界限的 API。
¥API for defining the boundary between modern and legacy JavaScript clients.
你可以使用此包定义浏览器引擎的最低浏览器版本,以确保其符合现代浏览器引擎的标准。所有未达到阈值的浏览器都将接收旧版软件包。这样,你就可以轻松地继续使用所需的现代功能。
¥You can use this package to define the minimum browser versions for which a browser engine will be considered modern. All browsers that do not meet the threshold will receive the legacy bundle. This way you can easily keep on using modern features that you need.
你可以在 Meteor 1.7 发布博客 中阅读更多相关信息。
¥You can read more about this in Meteor 1.7 announcement blog.
ModernBrowsers.isModern server only
server only
Summary:
Given a { name, major, minor, patch } object like the one provided by webapp via request.browser, return true if that browser qualifies as "modern" according to all requested version constraints.
Arguments:
Source codeName | Type | Description | Required |
---|---|---|---|
browser | object | { name: string, major: number, minor?: number, patch?: number } | No |
js
import { ModernBrowsers } from "meteor/modern-browsers";
/** @returns boolean */
const result = ModernBrowsers.isModern(
browser
);
ModernBrowsers.setMinimumBrowserVersions server only
server only
Summary:
Any package that depends on the modern-browsers package can call this function to communicate its expectations for the minimum browser versions that qualify as "modern." The final decision between web.browser.legacy and web.browser builds will be based on the maximum of all requested minimum versions for each browser.
Arguments:
Source codeName | Type | Description | Required |
---|---|---|---|
versions | object | Name of the browser engine and minimum version for at which it is considered modern. For example: { chrome: 49, edge: 12, ie: 12, firefox: 45, mobileSafari: 10, opera: 38, safari: 10, electron: [1, 6], } | Yes |
source | function | Name of the capability that requires these minimums. | Yes |
js
import { ModernBrowsers } from "meteor/modern-browsers";
ModernBrowsers.setMinimumBrowserVersions(
versions,
() => {},
);
ModernBrowsers.getMinimumBrowserVersions server only
server only
Summary:
Returns an object that lists supported browser engines and their minimum versions to be considered modern for Meteor.
ModernBrowsers.calculateHashOfMinimumVersions
Summary:
Creates a hash of the object of minimum browser versions.
将未知浏览器默认配置为现代浏览器
¥Configure Unknown Browsers to default to Modern
setMinimumBrowserVersions
中未明确列出的浏览器默认被视为 "legacy"。
¥Browsers not explicitly listed in setMinimumBrowserVersions
are considered "legacy" by default.
要更改此设置并将未知浏览器视为 "modern,",请在设置文件中更新相关选项:
¥To change this and treat unknown browsers as "modern," update the relevant option in your settings file:
js
Meteor.settings.packages = {
"modern-browsers": {
"unknownBrowsersAssumedModern": true
}
};