API能够作什么

  • APIs for manipulating documents loaded into the browser. The most obvious example is the DOM (Document Object Model) API, which allows you to manipulate HTML and CSS — creating, removing and changing HTML, dynamically applying new styles to your page, etc. Every time you see a popup window appear on a page, or some new content displayed, for example, that's the DOM in action. Find out more about these types of API in Manipulating documents.
  • (API用于操纵加载到浏览器中的文档。最明显的例子是DOM(文档对象模型)API,它容许您操做HTML和CSS——建立、删除和更改HTML、动态地向页面应用新样式等。帽子是行动的DOM。在操做文档时,了解更多的API类型。)
  • APIs that fetch data from the server to update small sections of a webpage on their own are very commonly used. This seemingly small detail has had a huge impact on the performance and behaviour of sites — if you just need to update a stock listing or list of available new stories, doing it instantly without having to reload the whole entire page from the server can make the site or app feel much more responsive and "snappy". APIs that make this possible include XMLHttpRequest and the Fetch API. You may also come across the term Ajax, which describes this technique. Find out more about such APIs in Fetching data from the server.
  • (从服务器获取数据以单独更新网页的小部分的API很是经常使用。这个看似很小的细节已经对网站的性能和行为产生了巨大的影响,若是您只须要更新一个股票列表或者可用的新故事列表,那么当即进行更新而没必要从服务器从新加载整个页面,就可使站点或者应用程序感受更轻松。颠簸和“快活”。使这成为可能的API包括XMLHtpRestQuess和FETCH API。您可能还会遇到术语Ajax,它描述了这种技术。从服务器获取数据时,了解更多关于API的信息。)
  • APIs for drawing and manipulating graphics are now widely supported in browsers — the most popular ones are Canvas and WebGL, which allow you to programmatically update the pixel data contained in an HTML <canvas> element to create 2D and 3D scenes. For example, you might draw shapes such as rectangles or circles, import an image onto the canvas, and apply a filter to it such as sepia or grayscale using the Canvas API, or create a complex 3D scene with lighting and textures using WebGL. Such APIs are often combined with APIs for creating animation loops (such as window.requestAnimationFrame()) and others to make constantly updating scenes like cartoons and games.
  • (用于绘制和操做图形的API如今在浏览器中获得了普遍的支持——最流行的是Canvas和WebGL,它们容许您经过编程方式更新HTML<canvas>元素中包含的像素数据,以建立2D和3D场景。例如,您能够绘制诸如矩形或圆形之类的形状,将图像导入到画布上,并使用画布API对图像应用过滤器,例如海皮或灰度,或者使用WebGL建立具备光照和纹理的复杂3D场景。这些API一般与API结合用于建立动画循环(例如window.request.tionFrame())和其余API,以便不断更新动画和游戏等场景。)
  • Audio and Video APIs like HTMLMediaElement, the Web Audio API, and WebRTC allow you to do really interesting things with multimedia such as creating custom UI controls for playing audio and video, displaying text tracks like captions and subtitles along with your videos, grabbing video from your web camera to be manipulated via a canvas (see above) or displayed on someone else's computer in a web conference, or adding effects to audio tracks (such as gain, distortion, panning, etc).
  • (像HTMLMediaElement、Web Audio API和WebRTC这样的音频和视频API容许您使用多媒体作一些很是有趣的事情,例如建立用于播放音频和视频的自定义UI控件、显示文本轨道(如字幕和字幕)以及视频、从咱们这里获取视频。b经过画布(参见上文)操纵的相机,或在网络会议中显示在其余人的计算机上,或向音频轨道添加效果(例如增益、失真、摇摄等)。)
  • Device APIs are basically APIs for manipulating and retrieving data from modern device hardware in a way that is useful for web apps. We've already talked about the Geolocation API accessing the device's location data so you can plot your position on a map. Other examples include telling the user that a useful update is available on a web app via system notifications (see the Notifications API) or vibration hardware (see the Vibration API).
  • (设备API基本上是用于以对网络应用程序有用的方式操纵和检索来自现代设备硬件的数据的API。咱们已经讨论了访问设备位置数据的地理定位API,以便您能够在地图上绘制位置。其余示例包括经过系统通知(参见Notifications API)或振动硬件(参见振动API)告诉用户web应用程序上有可用的更新。)
  • Client-side storage APIs are becoming a lot more widespread in web browsers — the ability to store data on the client-side is very useful if you want to create an app that will save its state between page loads, and perhaps even work when the device is offline. There are a number of options available, e.g. simple name/value storage with the Web Storage API, and more complex tabular data storage with the IndexedDB API.
  • 客户端存储API在网络浏览器中愈来愈广泛——若是您想要建立一个应用程序,能够在页面加载之间保存其状态,甚至在设备脱机时工做,那么在客户端存储数据的能力是很是有用的。有许多可用的选项,例如,使用Web Storage API的简单名称/值存储,以及使用IndexedDB API的更复杂的表格数据存储。

(源自于:https://www.cnblogs.com/lal520/p/9981411.html)html

相关文章
相关标签/搜索