博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
股票历史行情数据api_历史API
阅读量:2503 次
发布时间:2019-05-11

本文共 4620 字,大约阅读时间需要 15 分钟。

股票历史行情数据api

介绍 (Introduction)

The History API lets you interact with the browser history, trigger the browser navigation methods and change the address bar content.

History API使您可以与浏览器历史记录交互触发浏览器导航方法更改地址栏内容

It’s especially useful in combination with modern Single Page Applications, on which you never make a server-side request for new pages, but instead the page is always the same: just the internal content changes.

与现代的单页应用程序结合使用时特别有用,在该应用程序中,您永远不会在服务器端请求新页面,而是页面始终是相同的:只是内部内容发生了变化。

A modern JavaScript application running in the browser that does not interact with the History API, either explicitly or at the framework level, is going to be a poor experience to the user, since the back and forward buttons break.

在浏览器中运行的现代JavaScript应用程序 ,无论是显式的还是在框架级别上,都不会与History API进行交互,因为后退和前进按钮会中断 ,因此对于用户而言将是糟糕的体验。

Also, when navigating the app, the view changes but the address bar does not.

此外,在浏览应用程序时, 视图会更改,但地址栏不会更改

And also the reload button breaks: reloading the page, since there is no deep linking, is going to make the browser show a different page

重新加载按钮也中断 :由于没有深层链接,重新加载页面将使浏览器显示不同的页面

The History API was introduced in HTML5 and is now . IE supports it since version 10, and if you need to support IE9 and older, use the .

历史API是HTML5中引入的,现在 。 IE从版本10开始支持它,如果您需要支持IE9和更早的版本,请使用 。

访问历史记录API (Access the History API)

The History API is available on the window object, so you can call it like this: window.history or history, since window is the global object.

历史API是可用的window对象,所以你可以这样调用: window.historyhistory ,因为window是全局对象。

The History object

Let’s start with the simplest thing you can do with the History API.

让我们从您可以使用History API进行的最简单的操作开始。

Go back to the previous page:

返回上一个页面:

history.back()

this goes to the previous entry in the session history. You can forward to the next page using

这将转到会话历史记录中的上一个条目。 您可以使用转到下一页

history.forward()

This is exactly just like using the browser back and forward buttons.

这就像使用浏览器的后退和前进按钮一样。

go() lets you navigate back or forward multiple levels deep. For example

go()可让您深入浏览或前进多个级别。 例如

history.go(-1) //equivalent to history.back()history.go(-2) //equivalent to calling history.back() twicehistory.go(1) //equivalent to history.forward()history.go(3) //equivalent to calling history.forward() 3 times

To know how many entries there are in the history, you can call

要知道历史记录中有多少个条目,您可以致电

history.length

在历史记录中添加一个条目 (Add an entry to the history)

Using pushState() you can create a new history entry programmatically. You pass 3 parameters.

使用pushState()可以以编程方式创建新的历史记录条目。 您传递3个参数。

The first is an object which can contain anything (there is a size limit however, and the object needs to be serializable).

第一个是可以包含任何内容的对象(但是存在大小限制,并且该对象需要可序列化)。

The second parameter is currently unused by major browsers, so you generally pass an empty string.

当前主流浏览器未使用第二个参数,因此通常传递一个空字符串。

The third parameter is a URL associated to the new state. Note that the URL needs to belong to the same origin domain of the current URL.

第三个参数是与新状态关联的URL。 请注意,该URL必须属于当前URL的同一原始域。

const state = { name: 'Flavio' }history.pushState(state, '', '/user')

Calling this won’t change the content of the page, and does not cause any browser action like changing window.location would.

调用此操作不会更改页面的内容,并且不会引起任何浏览器操作,如更改window.location那样。

修改历史记录 (Modify history entries)

While pushState() lets you add a new state to the history, replaceState() allows you to edit the current history state.

虽然pushState()允许您向历史记录添加新状态,但是replaceState()允许您编辑当前历史记录状态。

history.pushState({}, '', '/posts')const state = { post: 'first' }history.pushState(state, '', '/post/first')const state = { post: 'second' }history.replaceState(state, '', '/post/second')

If you now call

如果您现在打电话

history.back()

the browser goes straight to /posts, since /post/first was replaced by /post/second

浏览器直接转到/posts ,因为/post/first/post/second 替换

访问当前历史记录输入状态 (Access the current history entry state)

Accessing the property

进入物业

history.state

returns the current state object (the first parameter passed to pushState or replaceState).

返回当前状态对象(传递给pushStatereplaceState的第一个参数)。

onpopstate事件 (The onpopstate event)

This event is called on window every time the active history state changes, with the current state as the callback parameter:

每次活动历史记录状态更改时,都会在window上调用此事件,并将当前状态作为回调参数:

window.onpopstate = event => {  console.log(event.state)}

will log the new state object (the first parameter passed to pushState or replaceState) every time you call history.back(), history.forward() or history.go().

每次调用history.back()history.forward()history.go() ,都会记录新的状态对象(传递给pushStatereplaceState的第一个参数history.go()

翻译自:

股票历史行情数据api

转载地址:http://iqqgb.baihongyu.com/

你可能感兴趣的文章
spring boot下MultipartHttpServletRequest如何提高上传文件大小的默认值
查看>>
css继承和边框圆角 及 写三角形
查看>>
编译opencv有关cuda的代码
查看>>
spring quartz job autowired 出错 null pointer
查看>>
openfire 安装部署
查看>>
数据库查询某一字段为空的数据
查看>>
GridView使用CommandField删除列实现删除时提示确认框
查看>>
23. CTF综合靶机渗透(十六)
查看>>
【caffe】train_lenet.sh在windows下的解决方案
查看>>
【机器学习】--回归问题的数值优化
查看>>
用C# 连接 hadoop,hive,hbase的一些代码
查看>>
Linux挂载U盘
查看>>
linux下LCD(framebuffer)驱动分析...
查看>>
FZu Problem 2233 ~APTX4869 (并查集 + sort)
查看>>
php程序面试题
查看>>
Hibernate one2one配置
查看>>
shiro 和 spring boot 的集成
查看>>
Tomcat - DBCP 配置
查看>>
Quartz Scheduler(2.2.1) - Working with TriggerListeners and JobListeners
查看>>
ActiveMQ(5.10.0) - Wildcards and composite destinations
查看>>