{"id":99,"date":"2018-04-13T16:13:02","date_gmt":"2018-04-13T08:13:02","guid":{"rendered":"http:\/\/blog.doublejia.cn\/?p=99"},"modified":"2018-04-13T16:13:02","modified_gmt":"2018-04-13T08:13:02","slug":"axios%e7%ac%94%e8%ae%b0","status":"publish","type":"post","link":"https:\/\/blog.doublejia.cn\/?p=99","title":{"rendered":"AXIOS\u7b14\u8bb0"},"content":{"rendered":"<p>1. axios.defaults.headers.post[&#039;Content-Type&#039;] = &#039;application\/x-www-form-urlencoded&#039;;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\u52a0\u4e0a\u8fd9\u4e2aheader\uff0c\u5728method&nbsp;\u662fPOST\u65f6\uff0cPHP\u53ef\u4ee5\u4f7f\u7528 $_POST&nbsp;\u83b7\u53d6\uff0c\u5426\u5219\u8981\u4f7f\u7528&nbsp;file_get_contents(&#039;php:\/\/input&#039;)\u3002<\/p>\n<p><\/p>\n<p>2. axios.defaults.withCredentials = true;&nbsp;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\u8de8\u57df\u65f6\uff0c\u5982\u679c\u8981\u4f7f\u7528Cookie\uff0c\u53ef\u4ee5\u52a0\u4e0a withCredentials= true\u3002<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\u540e\u7aef\u9875\u9762\uff0c\u4e5f\u9700\u8981\u52a0\u4e0a\u76f8\u5e94\u7684 header\u3002<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; header(&#039;Access-Control-Allow-Origin: http:\/\/localhost:8080&#039;);<\/p>\n<p><strong>&nbsp; &nbsp; &nbsp; &nbsp; header(&#039;Access-Control-Allow-Credentials: true&#039;);<\/strong><\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; header(&quot;Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE&quot;);<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; header(&#039;Access-Control-Allow-Headers:x-requested-with,content-type&#039;);<\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. axios.defaults.headers.post[&#039;Content-Type&#039;] = &#039;application\/x-www-form-urlencoded&#039;; &nbsp;&nbsp;&nbsp;&nbsp;\u52a0\u4e0a\u8fd9\u4e2aheader\uff0c\u5728method&nbsp;\u662fPOST\u65f6\uff0cPHP\u53ef\u4ee5\u4f7f\u7528 $_POST&nbsp;\u83b7\u53d6\uff0c\u5426\u5219\u8981\u4f7f\u7528&nbsp;file_\u2026<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.doublejia.cn\/index.php?rest_route=\/wp\/v2\/posts\/99"}],"collection":[{"href":"https:\/\/blog.doublejia.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.doublejia.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.doublejia.cn\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.doublejia.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=99"}],"version-history":[{"count":0,"href":"https:\/\/blog.doublejia.cn\/index.php?rest_route=\/wp\/v2\/posts\/99\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.doublejia.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=99"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.doublejia.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=99"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.doublejia.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}