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

相關文章
相關標籤/搜索