{"id":30264,"date":"2024-11-25T14:02:22","date_gmt":"2024-11-25T06:02:22","guid":{"rendered":"https:\/\/fwq.ai\/blog\/30264\/"},"modified":"2024-11-25T14:02:22","modified_gmt":"2024-11-25T06:02:22","slug":"%e5%be%ae%e4%bf%a1%e5%b0%8f%e7%a8%8b%e5%ba%8f%e4%b9%8b%e9%a1%b5%e9%9d%a2%e4%bc%a0%e5%80%bc%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/30264\/","title":{"rendered":"\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e4b\u9875\u9762\u4f20\u503c\u8be6\u89e3"},"content":{"rendered":"<p>\u6700\u8fd1\u7ec4\u91cc\u5f00\u53d1\u5c0f\u7a0b\u5e8f\uff0c\u9047\u5230\u4e86\u4e00\u4e2a\u524d\u7aef\u4e98\u53e4\u4e0d\u53d8\u7684\u8bdd\u9898\uff1a\u9875\u9762<br \/>\u521a\u5f00\u59cb\u4f7f\u7528\u8def\u5f84\u4f20\u53c2\u89e3\u51b3\uff0c\u4f46\u662f\u4f17\u6240\u5468\u77e5\uff1a<\/p>\n<blockquote><p>\n  \u5404\u6d4f\u89c8\u5668HTTP Get\u8bf7\u6c42URL\u6700\u5927\u957f\u5ea6\u5e76\u4e0d\u76f8\u540c\uff0c\u51e0\u7c7b\u5e38\u7528\u6d4f\u89c8\u5668\u6700\u5927\u957f\u5ea6\u53ca\u8d85\u8fc7\u6700\u5927\u957f\u5ea6\u540e\u63d0\u4ea4\u60c5\u51b5\u5982\u4e0b\uff1aIE6.0 :url\u6700\u5927\u957f\u5ea62083\u4e2a\u5b57\u7b26\uff0c\u8d85\u8fc7\u6700\u5927\u957f\u5ea6\u540e\u65e0\u6cd5\u63d0\u4ea4\u3002IE7.0 :url\u6700\u5927\u957f\u5ea62083\u4e2a\u5b57\u7b26\uff0c\u8d85\u8fc7\u6700\u5927\u957f\u5ea6\u540e\u4ecd\u7136\u80fd\u63d0\u4ea4\uff0c\u4f46\u662f\u53ea\u80fd\u4f20\u8fc7\u53bb2083\u4e2a\u5b57\u7b26\u3002firefox 3.0.3 :url\u6700\u5927\u957f\u5ea67764\u4e2a\u5b57\u7b26\uff0c\u8d85\u8fc7\u6700\u5927\u957f\u5ea6\u540e\u65e0\u6cd5\u63d0\u4ea4\u3002Opera 9.52 :url\u6700\u5927\u957f\u5ea67648\u4e2a\u5b57\u7b26\uff0c\u8d85\u8fc7\u6700\u5927\u957f\u5ea6\u540e\u65e0\u6cd5\u63d0\u4ea4\u3002Google Chrome 2.0.168 :url\u6700\u5927\u957f\u5ea67713\u4e2a\u5b57\u7b26\uff0c\u8d85\u8fc7\u6700\u5927\u957f\u5ea6\u540e\u65e0\u6cd5\u63d0\u4ea4\u3002\n<\/p><\/blockquote>\n<p>\u6240\u4ee5\u89c9\u5f97\u4e0d\u9760\u8c31\u3002<br \/>\u7814\u7a76\u4e86\u4e00\u4e0b\u5b98\u7f51\uff0c\u53d1\u73b0\u6709\u4e24\u79cd\u65b9\u5f0f\u53ef\u4ee5\u201c\u6bd4\u8f83\u4f18\u96c5\u201d\u5730\u5e72\u8fd9\u4ef6\u4e8b\uff0c\u5f53\u7136\u4e0d\u80fd\u548cvuex\/flux\u6bd4\u3002<\/p>\n<ol>\n<li>\n<p>\u4f7f\u7528\u5168\u5c40\u53d8\u91cf<br \/>\u5728\u9879\u76eeapp.js\u4e2d\u5b9a\u4e49globalData<\/p>\n<pre>App({\r\n&nbsp;globalData:{\r\n&nbsp;userInfo:'angeladaddy'\r\n}\r\n});<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u9700\u8981\u7684\u5730\u65b9\u4f7f\u7528\uff1a<\/p>\n<pre>getGlobalVar:function(){\r\n&nbsp;var&nbsp;that=this;\r\nthat.setData({\r\n&nbsp;&nbsp;globalvar_str:JSON.stringify(getApp().globalData)\r\n})&nbsp;\r\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5f53\u7136\u4e5f\u53ef\u4ee5\u968f\u65f6\u8d4b\u503c\uff1a<\/p>\n<pre>onLoad:function(options){\r\n&nbsp;getApp().globalData.userInfo+='&nbsp;is&nbsp;an&nbsp;awesome&nbsp;man';\r\n},<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6548\u679c\uff1a<\/p>\n<\/li>\n<\/ol>\n<p><img decoding=\"async\" src=\"https:\/\/upload-images.jianshu.io\/upload_images\/1431816-d07f99c1c01731e7.png?imageMogr2\/auto-orient\/strip%7CimageView2\/2\/w\/1240\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e4b\u9875\u9762\u4f20\u503c\u8be6\u89e3\u63d2\u56fe\" alt=\"\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e4b\u9875\u9762\u4f20\u503c\u8be6\u89e3\u63d2\u56fe\" \/><\/p>\n<p>Paste_Image.png<\/p>\n<p>2.\u4f7f\u7528\u6a21\u677f<br \/>\u6839\u636e\u5b98\u65b9\u4ecb\u7ecd\u5982\u4e0b\uff1a<\/p>\n<blockquote>\n<p>\u9996\u5148\u5b9a\u4e49\u6a21\u677f,\u4f7f\u7528name\u5c5e\u6027<\/p>\n<pre>&lt;template&gt;\r\n&nbsp;&nbsp;&lt;view&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;text&gt;&nbsp;{{index}}:&nbsp;{{msg}}&nbsp;&lt;\/text&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;text&gt;&nbsp;Time:&nbsp;{{time}}&nbsp;&lt;\/text&gt;\r\n&nbsp;&nbsp;&lt;\/view&gt;&lt;\/template&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u63a5\u7740\uff0c\u4f7f\u7528\u6a21\u677f<\/p>\n<ul>\n<li>\n<p>\u4f7f\u7528 is \u5c5e\u6027\uff0c\u58f0\u660e\u9700\u8981\u7684\u4f7f\u7528\u7684\u6a21\u677f\uff0c\u7136\u540e\u5c06\u6a21\u677f\u6240\u9700\u8981\u7684 data \u4f20\u5165\uff0c\u5982\uff1a<\/p>\n<pre>&lt;template&gt;&lt;\/template&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7ed9item\u8d4b\u503c\u4ee5\u663e\u793a\u6a21\u677f\u6570\u636e<\/p>\n<pre>Page({\r\ndata:&nbsp;{\r\n&nbsp;item:&nbsp;{\r\n&nbsp;&nbsp;&nbsp;index:&nbsp;0,\r\n&nbsp;&nbsp;&nbsp;msg:&nbsp;'this&nbsp;is&nbsp;a&nbsp;template',\r\n&nbsp;&nbsp;&nbsp;time:&nbsp;'2016-09-15'\r\n&nbsp;}\r\n}\r\n})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<\/blockquote>\n<h3>\u8fd9\u6837\u5c31\u201cduang~~~\u201d\u7684\u4e00\u4e0b\u89e3\u51b3\u4e86\u9875\u9762\u4f20\u503c\u95ee\u9898<\/h3>\n<blockquote>\n<p>\u540e\u8bb0\uff1a\u65e2\u7136\u5c0f\u7a0b\u5e8f\u53ef\u4ee5\u4f7f\u7528ES6\u7684\u6240\u6709\u7279\u6027\uff0c\u90a3\u4e48\u90a3\u4e2avar that=this\u53c8\u662f\u4ec0\u4e48\u9b3c\uff1f\u4e3a\u4f55\u4e0d\u80fd\u7528\u7bad\u5934\u51fd\u6570\u89e3\u51b3\u4f5c\u7528\u57df\u95ee\u9898\uff1f\u56de\u5934\u518d\u8bd5\u8bd5\u3002<\/p>\n<\/blockquote>\n<p>\u3010\u76f8\u5173\u63a8\u8350\u3011<\/p>\n<p>1. <\/p>\n<p>2.&nbsp;<\/p>\n<p>3.&nbsp;<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e4b\u9875\u9762\u4f20\u503c\u8be6\u89e3\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u7ec4\u91cc\u5f00\u53d1\u5c0f\u7a0b\u5e8f\uff0c\u9047\u5230\u4e86\u4e00\u4e2a\u524d\u7aef\u4e98\u53e4\u4e0d\u53d8\u7684\u8bdd\u9898\uff1a\u9875\u9762\u521a\u5f00\u59cb\u4f7f\u7528\u8def\u5f84\u4f20\u53c2\u89e3\u51b3\uff0c\u4f46\u662f\u4f17\u6240\u5468\u77e5\uff1a \u5404\u6d4f\u89c8\u5668HTTP Get\u8bf7\u6c42URL\u6700\u5927\u957f\u5ea6\u5e76\u4e0d\u76f8\u540c\uff0c\u51e0\u7c7b\u5e38\u7528\u6d4f\u89c8\u5668\u6700\u5927\u957f\u5ea6\u53ca\u8d85\u8fc7\u6700\u5927\u957f\u5ea6\u540e\u63d0\u4ea4\u60c5\u51b5\u5982\u4e0b\uff1aIE6.0 :url\u6700\u5927\u957f\u5ea62083\u4e2a\u5b57\u7b26\uff0c\u8d85\u8fc7\u6700\u5927\u957f\u5ea6\u540e\u65e0\u6cd5\u63d0\u4ea4\u3002IE7.0 :url\u6700\u5927\u957f\u5ea62083\u4e2a\u5b57\u7b26\uff0c\u8d85\u8fc7\u6700\u5927\u957f\u5ea6\u540e\u4ecd\u7136\u80fd\u63d0\u4ea4\uff0c\u4f46\u662f\u53ea\u80fd\u4f20\u8fc7\u53bb2083\u4e2a\u5b57\u7b26\u3002firefox 3.0.3 :url\u6700\u5927\u957f\u5ea67764\u4e2a\u5b57\u7b26\uff0c\u8d85\u8fc7\u6700\u5927\u957f\u5ea6\u540e\u65e0\u6cd5\u63d0\u4ea4\u3002Opera 9.52 :url\u6700\u5927\u957f\u5ea67648\u4e2a\u5b57\u7b26\uff0c\u8d85\u8fc7\u6700\u5927\u957f\u5ea6\u540e\u65e0\u6cd5\u63d0\u4ea4\u3002Google Chrome 2.0.168 :url\u6700\u5927\u957f\u5ea67713\u4e2a\u5b57\u7b26\uff0c\u8d85\u8fc7\u6700\u5927\u957f\u5ea6\u540e\u65e0\u6cd5\u63d0\u4ea4\u3002 \u6240\u4ee5\u89c9\u5f97\u4e0d\u9760\u8c31\u3002\u7814\u7a76\u4e86\u4e00\u4e0b\u5b98\u7f51\uff0c\u53d1\u73b0\u6709\u4e24\u79cd\u65b9\u5f0f\u53ef\u4ee5\u201c\u6bd4\u8f83\u4f18\u96c5\u201d\u5730\u5e72\u8fd9\u4ef6\u4e8b\uff0c\u5f53\u7136\u4e0d\u80fd\u548cvuex\/flux\u6bd4\u3002 \u4f7f\u7528\u5168\u5c40\u53d8\u91cf\u5728\u9879\u76eeapp.js\u4e2d\u5b9a\u4e49globalData App({ &nbsp;globalData:{ &nbsp;userInfo:&#8217;angeladaddy&#8217; } }); \u767b\u5f55\u540e\u590d\u5236 \u5728\u9700\u8981\u7684\u5730\u65b9\u4f7f\u7528\uff1a getGlobalVar:function(){ &nbsp;var&nbsp;that=this; that.setData({ &nbsp;&nbsp;globalvar_str:JSON.stringify(getApp().globalData) })&nbsp; } \u767b\u5f55\u540e\u590d\u5236 \u5f53\u7136\u4e5f\u53ef\u4ee5\u968f\u65f6\u8d4b\u503c\uff1a onLoad:function(options){ &nbsp;getApp().globalData.userInfo+=&#8217;&nbsp;is&nbsp;an&nbsp;awesome&nbsp;man&#8217;; }, \u767b\u5f55\u540e\u590d\u5236 \u6548\u679c\uff1a Paste_Image.png 2.\u4f7f\u7528\u6a21\u677f\u6839\u636e\u5b98\u65b9\u4ecb\u7ecd\u5982\u4e0b\uff1a \u9996\u5148\u5b9a\u4e49\u6a21\u677f,\u4f7f\u7528name\u5c5e\u6027 &lt;template&gt; &nbsp;&nbsp;&lt;view&gt; &nbsp;&nbsp;&nbsp;&nbsp;&lt;text&gt;&nbsp;{{index}}:&nbsp;{{msg}}&nbsp;&lt;\/text&gt; &nbsp;&nbsp;&nbsp;&nbsp;&lt;text&gt;&nbsp;Time:&nbsp;{{time}}&nbsp;&lt;\/text&gt; &nbsp;&nbsp;&lt;\/view&gt;&lt;\/template&gt; \u767b\u5f55\u540e\u590d\u5236 \u63a5\u7740\uff0c\u4f7f\u7528\u6a21\u677f \u4f7f\u7528 is \u5c5e\u6027\uff0c\u58f0\u660e\u9700\u8981\u7684\u4f7f\u7528\u7684\u6a21\u677f\uff0c\u7136\u540e\u5c06\u6a21\u677f\u6240\u9700\u8981\u7684 data \u4f20\u5165\uff0c\u5982\uff1a &lt;template&gt;&lt;\/template&gt; \u767b\u5f55\u540e\u590d\u5236 \u7ed9item\u8d4b\u503c\u4ee5\u663e\u793a\u6a21\u677f\u6570\u636e Page({ data:&nbsp;{ &nbsp;item:&nbsp;{ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-30264","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30264","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=30264"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30264\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=30264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=30264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=30264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}