{"id":52609,"date":"2024-12-03T12:16:23","date_gmt":"2024-12-03T04:16:23","guid":{"rendered":"https:\/\/fwq.ai\/blog\/52609\/"},"modified":"2024-12-03T12:16:23","modified_gmt":"2024-12-03T04:16:23","slug":"%e5%a6%82%e4%bd%95%e5%87%86%e7%a1%ae%e8%8e%b7%e5%8f%96%e6%b5%8f%e8%a7%88%e5%99%a8%e5%8e%86%e5%8f%b2%e8%ae%b0%e5%bd%95%e4%b8%ad%e5%bd%93%e5%89%8d%e9%a1%b5%e9%9d%a2%e7%9a%84%e4%bd%8d%e7%bd%ae%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/52609\/","title":{"rendered":"\u5982\u4f55\u51c6\u786e\u83b7\u53d6\u6d4f\u89c8\u5668\u5386\u53f2\u8bb0\u5f55\u4e2d\u5f53\u524d\u9875\u9762\u7684\u4f4d\u7f6e\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u5982\u4f55\u51c6\u786e\u83b7\u53d6\u6d4f\u89c8\u5668\u5386\u53f2\u8bb0\u5f55\u4e2d\u5f53\u524d\u9875\u9762\u7684\u4f4d\u7f6e\uff1f<\/h1>\n<p>\u5927\u5bb6\u597d\uff0c\u6211\u4eec\u53c8\u89c1\u9762\u4e86\u554a~\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5982\u4f55\u51c6\u786e\u83b7\u53d6\u6d4f\u89c8\u5668\u5386\u53f2\u8bb0\u5f55\u4e2d\u5f53\u524d\u9875\u9762\u7684\u4f4d\u7f6e\uff1f\u300b<\/span>\u7684\u5185\u5bb9\u4e2d\u5c06\u4f1a\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u3002\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u76f8\u5173\u77e5\u8bc6\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\uff0c\u4ee5\u540e\u4f1a\u7ed9\u5927\u5bb6\u5e26\u6765\u66f4\u591a<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u76f8\u5173\u6587\u7ae0\uff0c\u5e0c\u671b\u6211\u4eec\u80fd\u4e00\u8d77\u8fdb\u6b65\uff01\u4e0b\u9762\u5c31\u5f00\u59cb\u672c\u6587\u7684\u6b63\u5f0f\u5185\u5bb9~<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241122\/1732234192673fcbd034497.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u51c6\u786e\u83b7\u53d6\u6d4f\u89c8\u5668\u5386\u53f2\u8bb0\u5f55\u4e2d\u5f53\u524d\u9875\u9762\u7684\u4f4d\u7f6e\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u51c6\u786e\u83b7\u53d6\u6d4f\u89c8\u5668\u5386\u53f2\u8bb0\u5f55\u4e2d\u5f53\u524d\u9875\u9762\u7684\u4f4d\u7f6e\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u83b7\u53d6\u6d4f\u89c8\u5668\u5386\u53f2\u8bb0\u5f55\u4e2d\u5f53\u524d\u9875\u9762\u7684\u4f4d\u7f6e<\/strong><\/p>\n<p>\u8981\u786e\u5b9a\u5f53\u524d\u9875\u9762\u5728\u6d4f\u89c8\u5668\u5386\u53f2\u8bb0\u5f55\u6808\u4e2d\u7684\u4f4d\u7f6e\uff0c\u9700\u8981\u4e86\u89e3\u4ee5\u4e0b\u8981\u70b9\uff1a<\/p>\n<p><strong>1. \u59cb\u7ec8\u8fd4\u56de\u5386\u53f2\u6808\u957f\u5ea6<\/strong><\/p>\n<pre>console.log(history.length) \/\/  \u59cb\u7ec8\u8fd4\u56de\u5386\u53f2\u6808\u957f\u5ea6<\/pre>\n<p><strong>2. \u76d1\u542c popstate \u4e8b\u4ef6<\/strong><\/p>\n<p>\u5728\u5355\u9875\u5e94\u7528\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u76d1\u542c popstate \u4e8b\u4ef6\uff0c\u5e76\u624b\u52a8\u7ef4\u62a4\u4e00\u4e2a\u5386\u53f2\u6808\uff0c\u6765\u5f97\u77e5\u5f53\u524d\u9875\u9762\u4f4d\u7f6e\u3002<\/p>\n<p><strong>3. \u4f7f\u7528 navigation api<\/strong><\/p>\n<p>navigation api (en-us) \u63d0\u4f9b\u4e86 entries() \u65b9\u6cd5\uff0c\u53ef\u4ee5\u83b7\u53d6\u5f53\u524d\u9875\u9762\u5728\u5386\u53f2\u8bb0\u5f55\u4e2d\u7684\u4f4d\u7f6e\uff0c\u4f46\u517c\u5bb9\u6027\u8f83\u5dee\u3002<\/p>\n<pre>console.log(navigation.entries())<\/pre>\n<p><strong>\u517c\u5bb9\u6027<\/strong>\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u6d4f\u89c8\u5668<\/th>\n<th>\u517c\u5bb9\u6027<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>chrome<\/td>\n<td>\u826f\u597d<\/td>\n<\/tr>\n<tr>\n<td>firefox<\/td>\n<td>\u4ec5\u90e8\u5206\u652f\u6301<\/td>\n<\/tr>\n<tr>\n<td>safari<\/td>\n<td>\u4e0d\u652f\u6301<\/td>\n<\/tr>\n<tr>\n<td>edge<\/td>\n<td>\u826f\u597d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300a\u5982\u4f55\u51c6\u786e\u83b7\u53d6\u6d4f\u89c8\u5668\u5386\u53f2\u8bb0\u5f55\u4e2d\u5f53\u524d\u9875\u9762\u7684\u4f4d\u7f6e\uff1f\u300b\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u7ed9\u5927\u5bb6\u5206\u4eab\u66f4\u591a\u6587\u7ae0\u77e5\u8bc6\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   \u5982\u4f55\u4f7f\u7528 JavaScript \u548c jQuery \u5b9e\u73b0\u70b9\u51fb\u5207\u6362\u663e\u793a\u9009\u9879\uff1f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u51c6\u786e\u83b7\u53d6\u6d4f\u89c8\u5668\u5386\u53f2\u8bb0\u5f55\u4e2d\u5f53\u524d\u9875\u9762\u7684\u4f4d\u7f6e\uff1f \u5927\u5bb6\u597d\uff0c\u6211\u4eec\u53c8\u89c1\u9762\u4e86\u554a~\u672c\u6587\u300a\u5982\u4f55\u51c6\u786e\u83b7\u53d6\u6d4f\u89c8\u5668\u5386\u53f2\u8bb0\u5f55\u4e2d\u5f53\u524d\u9875\u9762\u7684\u4f4d\u7f6e\uff1f\u300b\u7684\u5185\u5bb9\u4e2d\u5c06\u4f1a\u6d89\u53ca\u5230\u7b49\u7b49\u3002\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\uff0c\u4ee5\u540e\u4f1a\u7ed9\u5927\u5bb6\u5e26\u6765\u66f4\u591a\u6587\u7ae0\u76f8\u5173\u6587\u7ae0\uff0c\u5e0c\u671b\u6211\u4eec\u80fd\u4e00\u8d77\u8fdb\u6b65\uff01\u4e0b\u9762\u5c31\u5f00\u59cb\u672c\u6587\u7684\u6b63\u5f0f\u5185\u5bb9~ \u5982\u4f55\u83b7\u53d6\u6d4f\u89c8\u5668\u5386\u53f2\u8bb0\u5f55\u4e2d\u5f53\u524d\u9875\u9762\u7684\u4f4d\u7f6e \u8981\u786e\u5b9a\u5f53\u524d\u9875\u9762\u5728\u6d4f\u89c8\u5668\u5386\u53f2\u8bb0\u5f55\u6808\u4e2d\u7684\u4f4d\u7f6e\uff0c\u9700\u8981\u4e86\u89e3\u4ee5\u4e0b\u8981\u70b9\uff1a 1. \u59cb\u7ec8\u8fd4\u56de\u5386\u53f2\u6808\u957f\u5ea6 console.log(history.length) \/\/ \u59cb\u7ec8\u8fd4\u56de\u5386\u53f2\u6808\u957f\u5ea6 2. \u76d1\u542c popstate \u4e8b\u4ef6 \u5728\u5355\u9875\u5e94\u7528\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u76d1\u542c popstate \u4e8b\u4ef6\uff0c\u5e76\u624b\u52a8\u7ef4\u62a4\u4e00\u4e2a\u5386\u53f2\u6808\uff0c\u6765\u5f97\u77e5\u5f53\u524d\u9875\u9762\u4f4d\u7f6e\u3002 3. \u4f7f\u7528 navigation api navigation api (en-us) \u63d0\u4f9b\u4e86 entries() \u65b9\u6cd5\uff0c\u53ef\u4ee5\u83b7\u53d6\u5f53\u524d\u9875\u9762\u5728\u5386\u53f2\u8bb0\u5f55\u4e2d\u7684\u4f4d\u7f6e\uff0c\u4f46\u517c\u5bb9\u6027\u8f83\u5dee\u3002 console.log(navigation.entries()) \u517c\u5bb9\u6027\uff1a \u6d4f\u89c8\u5668 \u517c\u5bb9\u6027 chrome \u826f\u597d firefox \u4ec5\u90e8\u5206\u652f\u6301 safari \u4e0d\u652f\u6301 edge \u826f\u597d \u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300a\u5982\u4f55\u51c6\u786e\u83b7\u53d6\u6d4f\u89c8\u5668\u5386\u53f2\u8bb0\u5f55\u4e2d\u5f53\u524d\u9875\u9762\u7684\u4f4d\u7f6e\uff1f\u300b\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u7ed9\u5927\u5bb6\u5206\u4eab\u66f4\u591a\u6587\u7ae0\u77e5\u8bc6\uff01 \u5982\u4f55\u4f7f\u7528 JavaScript \u548c jQuery \u5b9e\u73b0\u70b9\u51fb\u5207\u6362\u663e\u793a\u9009\u9879\uff1f<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-52609","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52609","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=52609"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52609\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=52609"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=52609"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=52609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}