From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/glossary/vendor_prefix/index.html | 77 +++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 files/zh-cn/glossary/vendor_prefix/index.html (limited to 'files/zh-cn/glossary/vendor_prefix') diff --git a/files/zh-cn/glossary/vendor_prefix/index.html b/files/zh-cn/glossary/vendor_prefix/index.html new file mode 100644 index 0000000000..cdf72cc791 --- /dev/null +++ b/files/zh-cn/glossary/vendor_prefix/index.html @@ -0,0 +1,77 @@ +--- +title: 浏览器引擎前缀 +slug: Glossary/Vendor_Prefix +tags: + - 术语 +translation_of: Glossary/Vendor_Prefix +--- +

浏览器厂商们有时会给实验性的或者非标准的 CSS 属性和 JavaScript API 添加前缀,这样开发者就可以用这些新的特性进行试验,同时(理论上)防止他们的试验代码被依赖,从而在标准化过程中破坏 web 开发者的代码。开发者应该等到浏览器行为标准化之后再使用未加前缀的属性。

+ +
+

浏览器厂商们正在努力停止使用前缀来表示实验性质的代码的行为。Web开发者一直在生产环境的网站上使用这些实验性代码,这使得浏览器厂商更难保证浏览器兼容性和处理新特性;这也伤害了更小众的浏览器,它们被迫添加其他浏览器前缀以加载热门网站。

+ +

现在的趋势是将实验性功能添加在需要用户自行设置偏好或标记(flag)的地方,同时编写一个更小规模的规范,以更快达到稳定状态。

+
+ +

CSS 前缀

+ +

主流浏览器引擎前缀:

+ + + +

示例:

+ +
-webkit-transition: all 4s ease;
+-moz-transition: all 4s ease;
+-ms-transition: all 4s ease;
+-o-transition: all 4s ease;
+transition: all 4s ease; 
+ +

API 前缀

+ +

过去,浏览器引擎也使用前缀修饰实验性质的API。如果整个接口都是实验性的,前缀修饰的就是接口名(但不包括其中的属性或者方法)。如果将一个实验性的接口或者方法添加到一个标准化的接口中,这个新增的接口或者方法被前缀修饰。 

+ +

接口前缀

+ +

需要使用大写的前缀修饰接口名:

+ + + +

属性和方法前缀

+ +

需要使用小写的前缀修饰属性或者方法

+ + + +

示例:

+ +
var requestAnimationFrame = window.requestAnimationFrame ||
+                            window.mozRequestAnimationFrame ||
+                            window.webkitRequestAnimationFrame ||
+                            window.oRequestAnimationFrame ||
+                            window.msRequestAnimationFrame;
+ +

了解更多

+ +

基础知识

+ + + +

{{QuickLinksWithSubpages("/zh-CN/docs/Glossary")}}

-- cgit v1.2.3-54-g00ecf