{"id":24618,"date":"2025-04-19T10:28:58","date_gmt":"2025-04-19T02:28:58","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/24618.html"},"modified":"2025-04-19T10:28:58","modified_gmt":"2025-04-19T02:28:58","slug":"%e4%bd%bf%e7%94%a8hash%e5%92%8chtml5%e7%9a%84history-api%e5%ae%9e%e7%8e%b0%e5%89%8d%e7%ab%af%e8%b7%af%e7%94%b1","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/24618.html","title":{"rendered":"\u4f7f\u7528Hash\u548cHTML5\u7684History API\u5b9e\u73b0\u524d\u7aef\u8def\u7531"},"content":{"rendered":"<h2>\u4f7f\u7528Hash\u548cHTML5\u7684History API\u5b9e\u73b0\u524d\u7aef\u8def\u7531<\/h2>\n<p>\u5728\u524d\u7aef\u5f00\u53d1\u4e2d&#xff0c;\u5b9e\u73b0\u8def\u7531\u673a\u5236\u53ef\u4ee5\u8ba9\u5355\u9875\u5e94\u7528&#xff08;SPA&#xff09;\u5728\u4e0d\u5237\u65b0\u9875\u9762\u7684\u60c5\u51b5\u4e0b&#xff0c;\u6839\u636e\u7528\u6237\u7684\u64cd\u4f5c\u663e\u793a\u4e0d\u540c\u7684\u5185\u5bb9\u3002\u4f7f\u7528Hash\u548cHTML5\u7684History API\u662f\u5b9e\u73b0\u524d\u7aef\u8def\u7531\u7684\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\u3002<\/p>\n<h4>\u4f7f\u7528Hash\u5b9e\u73b0\u524d\u7aef\u8def\u7531<\/h4>\n<li>\n<p>\u57fa\u672c\u539f\u7406&#xff1a;<\/p>\n<ul>\n<li>Hash\u5373URL\u4e2d\u7684#\u53ca\u5176\u540e\u9762\u7684\u90e8\u5206&#xff0c;\u4f8b\u5982http:\/\/example.com\/#\/page1\u3002<\/li>\n<li>\u5f53Hash\u53d8\u5316\u65f6&#xff0c;\u4e0d\u4f1a\u5411\u670d\u52a1\u5668\u53d1\u9001\u8bf7\u6c42&#xff0c;\u53ea\u4f1a\u89e6\u53d1\u6d4f\u89c8\u5668\u7684\u4e8b\u4ef6&#xff08;hashchange\u4e8b\u4ef6&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u5b9e\u73b0\u6b65\u9aa4&#xff1a;<\/p>\n<ul>\n<li>\u76d1\u542chashchange\u4e8b\u4ef6\u3002<\/li>\n<li>\u5728\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u4e2d&#xff0c;\u6839\u636e\u5f53\u524d\u7684Hash\u503c&#xff0c;\u6e32\u67d3\u5bf9\u5e94\u7684\u9875\u9762\u5185\u5bb9\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u793a\u4f8b\u4ee3\u7801&#xff1a;<\/p>\n<p> <span class=\"token keyword\">function<\/span> <span class=\"token function\">renderContent<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">hash<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">const<\/span> mainContent <span class=\"token operator\">&#061;<\/span> document<span class=\"token punctuation\">.<\/span><span class=\"token function\">getElementById<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;main-content&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">switch<\/span> <span class=\"token punctuation\">(<\/span>hash<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">case<\/span> <span class=\"token string\">&#039;#\/page1&#039;<\/span><span class=\"token operator\">:<\/span><br \/>\n            mainContent<span class=\"token punctuation\">.<\/span>innerHTML <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;This is Page 1&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token keyword\">break<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">case<\/span> <span class=\"token string\">&#039;#\/page2&#039;<\/span><span class=\"token operator\">:<\/span><br \/>\n            mainContent<span class=\"token punctuation\">.<\/span>innerHTML <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;This is Page 2&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token keyword\">break<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">default<\/span><span class=\"token operator\">:<\/span><br \/>\n            mainContent<span class=\"token punctuation\">.<\/span>innerHTML <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;Home Page&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token keyword\">break<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>window<span class=\"token punctuation\">.<\/span><span class=\"token function\">addEventListener<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;hashchange&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">const<\/span> hash <span class=\"token operator\">&#061;<\/span> window<span class=\"token punctuation\">.<\/span>location<span class=\"token punctuation\">.<\/span>hash<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">renderContent<\/span><span class=\"token punctuation\">(<\/span>hash<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u521d\u59cb\u52a0\u8f7d<\/span><br \/>\n<span class=\"token function\">renderContent<\/span><span class=\"token punctuation\">(<\/span>window<span class=\"token punctuation\">.<\/span>location<span class=\"token punctuation\">.<\/span>hash <span class=\"token operator\">||<\/span> <span class=\"token string\">&#039;#\/&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n <\/li>\n<h4>\u4f7f\u7528HTML5 History API\u5b9e\u73b0\u524d\u7aef\u8def\u7531<\/h4>\n<li>\n<p>\u57fa\u672c\u539f\u7406&#xff1a;<\/p>\n<ul>\n<li>HTML5 History API\u63d0\u4f9b\u4e86pushState\u548creplaceState\u65b9\u6cd5&#xff0c;\u53ef\u4ee5\u7528\u6765\u6539\u53d8\u5f53\u524dURL\u800c\u4e0d\u5237\u65b0\u9875\u9762\u3002<\/li>\n<li>\u76d1\u542cpopstate\u4e8b\u4ef6\u6765\u5904\u7406\u6d4f\u89c8\u5668\u7684\u524d\u8fdb\u548c\u540e\u9000\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u5b9e\u73b0\u6b65\u9aa4&#xff1a;<\/p>\n<ul>\n<li>\u4f7f\u7528pushState\u65b9\u6cd5\u5728\u7528\u6237\u64cd\u4f5c\u65f6\u6539\u53d8URL\u3002<\/li>\n<li>\u76d1\u542cpopstate\u4e8b\u4ef6&#xff0c;\u6839\u636e\u5f53\u524d\u7684URL\u6e32\u67d3\u5bf9\u5e94\u7684\u9875\u9762\u5185\u5bb9\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u793a\u4f8b\u4ee3\u7801&#xff1a;<\/p>\n<p> <span class=\"token keyword\">function<\/span> <span class=\"token function\">renderContent<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">path<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">const<\/span> mainContent <span class=\"token operator\">&#061;<\/span> document<span class=\"token punctuation\">.<\/span><span class=\"token function\">getElementById<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;main-content&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">switch<\/span> <span class=\"token punctuation\">(<\/span>path<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">case<\/span> <span class=\"token string\">&#039;\/page1&#039;<\/span><span class=\"token operator\">:<\/span><br \/>\n            mainContent<span class=\"token punctuation\">.<\/span>innerHTML <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;This is Page 1&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token keyword\">break<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">case<\/span> <span class=\"token string\">&#039;\/page2&#039;<\/span><span class=\"token operator\">:<\/span><br \/>\n            mainContent<span class=\"token punctuation\">.<\/span>innerHTML <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;This is Page 2&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token keyword\">break<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">default<\/span><span class=\"token operator\">:<\/span><br \/>\n            mainContent<span class=\"token punctuation\">.<\/span>innerHTML <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;Home Page&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n            <span class=\"token keyword\">break<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">function<\/span> <span class=\"token function\">navigateTo<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">path<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    history<span class=\"token punctuation\">.<\/span><span class=\"token function\">pushState<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span> path <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;&#039;<\/span><span class=\"token punctuation\">,<\/span> path<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">renderContent<\/span><span class=\"token punctuation\">(<\/span>path<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>window<span class=\"token punctuation\">.<\/span><span class=\"token function\">addEventListener<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;popstate&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">event<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">const<\/span> path <span class=\"token operator\">&#061;<\/span> event<span class=\"token punctuation\">.<\/span>state <span class=\"token operator\">&amp;&amp;<\/span> event<span class=\"token punctuation\">.<\/span>state<span class=\"token punctuation\">.<\/span>path<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">renderContent<\/span><span class=\"token punctuation\">(<\/span>path <span class=\"token operator\">||<\/span> <span class=\"token string\">&#039;\/&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u7ed1\u5b9a\u70b9\u51fb\u4e8b\u4ef6\u793a\u4f8b<\/span><br \/>\ndocument<span class=\"token punctuation\">.<\/span><span class=\"token function\">getElementById<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;link-page1&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">addEventListener<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;click&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">e<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    e<span class=\"token punctuation\">.<\/span><span class=\"token function\">preventDefault<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">navigateTo<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;\/page1&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>document<span class=\"token punctuation\">.<\/span><span class=\"token function\">getElementById<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;link-page2&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">addEventListener<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;click&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token parameter\">e<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    e<span class=\"token punctuation\">.<\/span><span class=\"token function\">preventDefault<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">navigateTo<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;\/page2&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u521d\u59cb\u52a0\u8f7d<\/span><br \/>\n<span class=\"token function\">renderContent<\/span><span class=\"token punctuation\">(<\/span>window<span class=\"token punctuation\">.<\/span>location<span class=\"token punctuation\">.<\/span>pathname<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n <\/li>\n<h4>\u5bf9\u6bd4\u4e0e\u9009\u62e9<\/h4>\n<ul>\n<li>\n<p>Hash\u6a21\u5f0f&#xff1a;<\/p>\n<ul>\n<li>\u517c\u5bb9\u6027\u597d&#xff0c;\u5373\u4f7f\u5728\u65e7\u7684\u6d4f\u89c8\u5668\u4e2d\u4e5f\u80fd\u6b63\u5e38\u5de5\u4f5c\u3002<\/li>\n<li>URL\u4e2d\u5305\u542b#&#xff0c;\u53ef\u80fd\u4e0d\u7b26\u5408\u67d0\u4e9bURL\u7f8e\u89c2\u7684\u8981\u6c42\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>History API\u6a21\u5f0f&#xff1a;<\/p>\n<ul>\n<li>URL\u66f4\u7f8e\u89c2&#xff0c;\u770b\u8d77\u6765\u66f4\u50cf\u4f20\u7edf\u7684\u591a\u9875\u5e94\u7528\u3002<\/li>\n<li>\u9700\u8981\u670d\u52a1\u5668\u914d\u7f6e\u652f\u6301&#xff0c;\u5bf9\u4e8e\u4e0d\u5b58\u5728\u7684URL\u8bf7\u6c42\u5e94\u8fd4\u56de\u5355\u9875\u5e94\u7528\u7684\u5165\u53e3HTML\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u6839\u636e\u9879\u76ee\u7684\u5177\u4f53\u9700\u6c42\u548c\u6d4f\u89c8\u5668\u517c\u5bb9\u6027\u8981\u6c42&#xff0c;\u53ef\u4ee5\u9009\u62e9\u5408\u9002\u7684\u8def\u7531\u5b9e\u73b0\u65b9\u5f0f\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d&#xff0c;\u901a\u5e38\u4f1a\u4f7f\u7528\u524d\u7aef\u6846\u67b6&#xff08;\u5982React\u3001Vue\u7b49&#xff09;\u63d0\u4f9b\u7684\u8def\u7531\u5e93&#xff08;\u5982React Router\u3001Vue Router&#xff09;&#xff0c;\u8fd9\u4e9b\u5e93\u5e95\u5c42\u5b9e\u73b0\u4e86\u4e0a\u8ff0\u539f\u7406&#xff0c;\u5e76\u63d0\u4f9b\u4e86\u66f4\u9ad8\u7ea7\u548c\u6613\u7528\u7684API\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.3k\u6b21\uff0c\u70b9\u8d5e11\u6b21\uff0c\u6536\u85cf6\u6b21\u3002\u5728\u524d\u7aef\u5f00\u53d1\u4e2d\uff0c\u5b9e\u73b0\u8def\u7531\u673a\u5236\u53ef\u4ee5\u8ba9\u5355\u9875\u5e94\u7528\uff08SPA\uff09\u5728\u4e0d\u5237\u65b0\u9875\u9762\u7684\u60c5\u51b5\u4e0b\uff0c\u6839\u636e\u7528\u6237\u7684\u64cd\u4f5c\u663e\u793a\u4e0d\u540c\u7684\u5185\u5bb9\u3002\u4f7f\u7528Hash\u548cHTML5\u7684History API\u662f\u5b9e\u73b0\u524d\u7aef\u8def\u7531\u7684\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\u3002_history h5 \u76d1\u542c\u53d8\u5316<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[964,187,87],"topic":[],"class_list":["post-24618","post","type-post","status-publish","format-standard","hentry","category-server","tag-html5","tag-javascript","tag-87"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4f7f\u7528Hash\u548cHTML5\u7684History API\u5b9e\u73b0\u524d\u7aef\u8def\u7531 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/24618.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f7f\u7528Hash\u548cHTML5\u7684History API\u5b9e\u73b0\u524d\u7aef\u8def\u7531 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.3k\u6b21\uff0c\u70b9\u8d5e11\u6b21\uff0c\u6536\u85cf6\u6b21\u3002\u5728\u524d\u7aef\u5f00\u53d1\u4e2d\uff0c\u5b9e\u73b0\u8def\u7531\u673a\u5236\u53ef\u4ee5\u8ba9\u5355\u9875\u5e94\u7528\uff08SPA\uff09\u5728\u4e0d\u5237\u65b0\u9875\u9762\u7684\u60c5\u51b5\u4e0b\uff0c\u6839\u636e\u7528\u6237\u7684\u64cd\u4f5c\u663e\u793a\u4e0d\u540c\u7684\u5185\u5bb9\u3002\u4f7f\u7528Hash\u548cHTML5\u7684History API\u662f\u5b9e\u73b0\u524d\u7aef\u8def\u7531\u7684\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\u3002_history h5 \u76d1\u542c\u53d8\u5316\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/24618.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-19T02:28:58+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/24618.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/24618.html\",\"name\":\"\u4f7f\u7528Hash\u548cHTML5\u7684History API\u5b9e\u73b0\u524d\u7aef\u8def\u7531 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-19T02:28:58+00:00\",\"dateModified\":\"2025-04-19T02:28:58+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/24618.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/24618.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/24618.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f7f\u7528Hash\u548cHTML5\u7684History API\u5b9e\u73b0\u524d\u7aef\u8def\u7531\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4f7f\u7528Hash\u548cHTML5\u7684History API\u5b9e\u73b0\u524d\u7aef\u8def\u7531 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/24618.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4f7f\u7528Hash\u548cHTML5\u7684History API\u5b9e\u73b0\u524d\u7aef\u8def\u7531 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.3k\u6b21\uff0c\u70b9\u8d5e11\u6b21\uff0c\u6536\u85cf6\u6b21\u3002\u5728\u524d\u7aef\u5f00\u53d1\u4e2d\uff0c\u5b9e\u73b0\u8def\u7531\u673a\u5236\u53ef\u4ee5\u8ba9\u5355\u9875\u5e94\u7528\uff08SPA\uff09\u5728\u4e0d\u5237\u65b0\u9875\u9762\u7684\u60c5\u51b5\u4e0b\uff0c\u6839\u636e\u7528\u6237\u7684\u64cd\u4f5c\u663e\u793a\u4e0d\u540c\u7684\u5185\u5bb9\u3002\u4f7f\u7528Hash\u548cHTML5\u7684History API\u662f\u5b9e\u73b0\u524d\u7aef\u8def\u7531\u7684\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\u3002_history h5 \u76d1\u542c\u53d8\u5316","og_url":"https:\/\/www.wsisp.com\/helps\/24618.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-19T02:28:58+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/24618.html","url":"https:\/\/www.wsisp.com\/helps\/24618.html","name":"\u4f7f\u7528Hash\u548cHTML5\u7684History API\u5b9e\u73b0\u524d\u7aef\u8def\u7531 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-19T02:28:58+00:00","dateModified":"2025-04-19T02:28:58+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/24618.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/24618.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/24618.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4f7f\u7528Hash\u548cHTML5\u7684History API\u5b9e\u73b0\u524d\u7aef\u8def\u7531"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/24618","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=24618"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/24618\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=24618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=24618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=24618"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=24618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}