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)

转载于:https://www.cnblogs.com/luoyiling/p/10003333.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值