{"id":740,"date":"2023-07-06T08:51:38","date_gmt":"2023-07-06T00:51:38","guid":{"rendered":"http:\/\/gjweb.top\/?p=740"},"modified":"2023-07-06T08:51:39","modified_gmt":"2023-07-06T00:51:39","slug":"%e6%9c%8d%e5%8a%a1%e7%ab%af%e6%b8%b2%e6%9f%93%e6%80%bb%e7%bb%93","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=740","title":{"rendered":"\u670d\u52a1\u7aef\u6e32\u67d3\u603b\u7ed3"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"\u521b\u5efa\u9879\u76ee\">\u521b\u5efa\u9879\u76ee<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>yarn create nuxt-app &lt;project-name&gt;<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u5f15\u5165\u7b2c\u4e09\u65b9ui\">\u5f15\u5165\u7b2c\u4e09\u65b9UI<\/h2>\n\n\n\n<p>\u4ee5 Element UI \u4e3a\u4f8b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yarn add element-ui -S<\/code><\/pre>\n\n\n\n<p>\u5728 plugins \/ element-ui.js<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import Vue from \"vue\"<br>import Element from \"element-ui\"<br>Vue.use(Element)<\/code><\/pre>\n\n\n\n<p>\u914d\u7f6e nuxt.config.js<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>plugin:&#91;<br> &nbsp; &nbsp;\"@\/plugins\/elemen-ui.js\"<br>],<br>css:&#91;<br> &nbsp; &nbsp;\"element-ui\/lib\/theme-chalk\/index.css\"<br>]<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u9759\u6001\u8def\u7531\u4e0e\u52a8\u6001\u8def\u7531\">\u9759\u6001\u8def\u7531\u4e0e\u52a8\u6001\u8def\u7531<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u9759\u6001\u8def\u7531\">\u9759\u6001\u8def\u7531<\/h3>\n\n\n\n<p>\u5728 page \u6587\u4ef6\u4e2d\u521b\u5efa\u7684\u76ee\u5f55\u7ed3\u6784\u9ed8\u8ba4\u4e3a\u9759\u6001\u8def\u7531\u7684\u8def\u5f84<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u52a8\u6001\u8def\u7531\">\u52a8\u6001\u8def\u7531<\/h3>\n\n\n\n<p>\u4f7f\u7528 \u4e0b\u5212\u7ebf + \u540d\u79f0 \u521b\u5efa\u7684\u6587\u4ef6\u4e3a\u52a8\u6001\u8def\u7531\uff1b\u4f8b\u5982 \uff1a_id.vue<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u83b7\u53d6\u52a8\u6001\u8def\u7531\u7684\u53c2\u6570\">\u83b7\u53d6\u52a8\u6001\u8def\u7531\u7684\u53c2\u6570<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;template&gt;<br>    &lt;div&gt;{{id}}&lt;\/div&gt;<br>&lt;\/template&gt;<br>&lt;script&gt;<br>export default {<br> &nbsp; &nbsp;\/\/ nuxt\u7684\u751f\u547d\u5468\u671f<br> &nbsp; &nbsp;asyncData({params}){<br> &nbsp; &nbsp; &nbsp; &nbsp;const id = params.id;<br> &nbsp; &nbsp; &nbsp; &nbsp;return {id}<br> &nbsp;  }<br>}<br>&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u5e03\u5c40\">\u5e03\u5c40<\/h2>\n\n\n\n<p>\u5728 layouts \u6587\u4ef6\u4e2d\u521b\u5efa default.vue \u548c error.vue \u5206\u522b\u7528\u4e8e\u9ed8\u8ba4\u7684\u5e03\u5c40\u548c\u5f02\u5e38\u9875\u9762\u8df3\u8f6c\u7684\u5e03\u5c40\u9875\u9762<\/p>\n\n\n\n<p>\u521b\u5efa default.vue<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;template&gt;<br>    &lt;div&gt;<br> &nbsp;      &lt;header&gt;\u5934\u90e8\u6a21\u5757&lt;\/header&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;main&gt; &lt;Nuxt\/&gt; &lt;\/main&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;footer&gt;\u5c3e\u90e8\u6a21\u5757&lt;\/footer&gt;<br> &nbsp; &nbsp;&lt;\/div&gt;<br>&lt;\/template&gt;<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528 &lt;Nuxt\/&gt; \u6a21\u5757\u5d4c\u5957 page \u4e2d\u7684\u9875\u9762<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u81ea\u5b9a\u4e49\u5e03\u5c40\u6587\u4ef6\">\u81ea\u5b9a\u4e49\u5e03\u5c40\u6587\u4ef6<\/h3>\n\n\n\n<p>\u5728 layouts \u4e2d\u521b\u5efa new_layout.vue \u6587\u4ef6<\/p>\n\n\n\n<p>\u5728 pages \u6587\u4ef6\u4e2d index.vue \u4e2d\u914d\u7f6e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;script&gt;<br>export default {<br>    layout:\"new_layout\"<br>}<br>&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u914d\u7f6e-axios-\u548c\u5f00\u53d1\u73af\u5883\u7684\u4ee3\u7406\">\u914d\u7f6e axios \u548c\u5f00\u53d1\u73af\u5883\u7684\u4ee3\u7406<\/h2>\n\n\n\n<p>\u5728 nuxt.config.js \u6587\u4ef6\u4e2d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>axios:{<br> &nbsp; &nbsp;base:'http:\/\/xxx.xxx'<br>},<br>proxy:{<br> &nbsp; &nbsp;\"\/api\/\":{<br> &nbsp; &nbsp; &nbsp; &nbsp;target:\"http:\/\/xxx.xxx\"<br> &nbsp;  }<br>}<br>\u200b<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u521b\u5efa\u9879\u76ee \u5f15\u5165\u7b2c\u4e09\u65b9UI \u4ee5 Element UI \u4e3a\u4f8b \u5728 plugins \/ element-ui.js  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[65],"tags":[],"class_list":["post-740","post","type-post","status-publish","format-standard","hentry","category-vue"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/740","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=740"}],"version-history":[{"count":1,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/740\/revisions"}],"predecessor-version":[{"id":741,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/740\/revisions\/741"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}