{"id":180,"date":"2020-06-11T13:47:59","date_gmt":"2020-06-11T05:47:59","guid":{"rendered":"http:\/\/zhuxinyong.com\/?p=180"},"modified":"2021-01-19T15:36:11","modified_gmt":"2021-01-19T07:36:11","slug":"%e5%a6%82%e4%bd%95%e5%8a%a8%e6%80%81%e6%9b%b4%e6%94%b9element-ui%e7%bb%84%e4%bb%b6%e5%b0%ba%e5%af%b8%e4%bb%a5%e5%8f%8a%e6%ba%90%e7%a0%81%e5%88%86%e6%9e%90","status":"publish","type":"post","link":"https:\/\/zhuxinyong.com\/?p=180","title":{"rendered":"\u5982\u4f55\u52a8\u6001\u66f4\u6539Element-UI\u7ec4\u4ef6\u5c3a\u5bf8\u4ee5\u53ca\u6e90\u7801\u5206\u6790"},"content":{"rendered":"\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"227\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/01\/420e811a8fa42a3c7df5d6010ae81bc9.jpg\" alt=\"\" class=\"wp-image-425\" srcset=\"https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/01\/420e811a8fa42a3c7df5d6010ae81bc9.jpg 640w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/01\/420e811a8fa42a3c7df5d6010ae81bc9-300x106.jpg 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure><\/div>\n\n\n\n<p>\u8fd9\u7bc7\u6587\u7ae0\u6e90\u4e8e\u4e00\u4e2a\u95ee\u9898\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"754\" height=\"558\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/01\/WechatIMG1015.jpeg\" alt=\"\" class=\"wp-image-427\" srcset=\"https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/01\/WechatIMG1015.jpeg 754w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/01\/WechatIMG1015-300x222.jpeg 300w\" sizes=\"auto, (max-width: 754px) 100vw, 754px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u5982\u4f55\u66f4\u6539\u5c3a\u5bf8\uff1f<\/strong><\/h2>\n\n\n\n<p>\u6211\u770b\u4e86\u53ea\u6709\u4e00\u4e2a\u56de\u7b54\uff0c\u8c8c\u4f3c\u7b54\u7684\u4e5f\u4e0d\u5bf9\uff0c\u4e0b\u9762\u8bf4\u4e00\u4e0b\u6211\u7684\u7b54\u6848\uff0c\u5176\u5b9e\u662f vue-element-admin \u7684\u5b9e\u73b0\u65b9\u6848\uff1a<br>\u5728 Vue \u9879\u76ee\u5165\u53e3\u6587\u4ef6\u4e2d\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Vue.use(Element, {\n  size: Cookies.get('size') || 'medium', \/\/ \u8bbe\u7f6e\u9ed8\u8ba4\u548c\u5237\u65b0\u6d4f\u89c8\u5668\u8bbe\u7f6e\u4e3a\u4f60\u6307\u5b9a\u7684\u5927\u5c0f\n  locale: enLang, \/\/ \u5982\u679c\u4f7f\u7528\u4e2d\u6587\uff0c\u65e0\u9700\u8bbe\u7f6e\uff0c\u8bf7\u5220\u9664\n})<\/pre>\n\n\n\n<p>\u66f4\u6539\u7ec4\u4ef6\u5c3a\u5bf8\u7684\u4e8b\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">methods:{\n    handleSetSize(size) {\n      this.$ELEMENT.size = size  \/\/ \u8fd9\u4e00\u6b65\u5f88\u5173\u952e\uff0c\u8fd9\u662f Element-UI \u5411 Vue \u66b4\u9732\u7684\u5b9e\u4f8b\u5c5e\u6027\uff0c\u4e0b\u9762\u4f1a\u6e90\u7801\u5206\u6790\n      this.$store.dispatch('app\/setSize', size) \/\/ \u8fd9\u91cc\u5c31\u662f\u628a\u5c3a\u5bf8\u5199\u5165 cookie \uff1aCookies.set('size', size)\uff0c\u4f9b\u9875\u9762\u5237\u65b0\u65f6\u4f7f\u7528\n      this.refreshView() \/\/ \u4e3b\u8981\u4e3a\u4e86\u53ca\u65f6\u5f53\u524d\u9875\u9762\u751f\u6548\uff0c\u8fd9\u4e2a\u5237\u65b0\u5355\u9875\u5e94\u7528\u7684\u65b9\u6848\u503c\u5f97\u5b66\u4e60\uff0c\u4e0b\u9762\u4e5f\u4f1a\u5206\u6790\u6e90\u7801\n      this.$message({\n        message: 'Switch Size Success',\n        type: 'success',\n      })\n    },\n    refreshView() {\n      \/\/ In order to make the cached page re-rendered\n      this.$store.dispatch('tagsView\/delAllCachedViews', this.$route)\n\n      const { fullPath } = this.$route\n      \/\/ \u8fd9\u91cc\u4f7f\u7528 nextTick \u662f\u4e3a\u4e86\u786e\u4fdd\u4e0a\u9762\u7684 dispatch \u91cc promise \u5f02\u6b65\u6e05\u9664\u7684\u4efb\u52a1\u5b8c\u6210\n      this.$nextTick(() =&amp;gt; {\n        this.$router.replace({\n          path: '\/redirect' + fullPath,\n        })\n      })\n    },\n}<\/pre>\n\n\n\n<p>redirect \u8def\u7531\u5b9a\u4e49\u4ee5\u53ca\u5bf9\u5e94\u7684\u7ec4\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n    path: '\/redirect',\n    component: Layout,\n    hidden: true,\n    children: [\n      {\n        path: '\/redirect\/:path(.*)', \/\/ \u8fd9\u91cc\u662f\u91cd\u70b9,\u89c1\u4e0b\u56fe\u8def\u7531\u524d\u540e\u5bf9\u6bd4\n        component: () =&amp;gt; import('@\/views\/backup\/redirect\/index'),\n      },\n    ],\n  },<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2020\/06\/2.jpg\" alt=\"\" class=\"wp-image-183\"\/><figcaption><br><\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2020\/06\/carbon-1-1024x482.png\" alt=\"\" class=\"wp-image-188\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>ELement-UI \u91cc\u7ec4\u4ef6\u662f\u5982\u4f55\u4f7f\u7528 $ELEMENT.size \u7684\uff1f<\/strong><\/h2>\n\n\n\n<p>\u4ee5 Button \u7ec4\u4ef6\u4e3a\u4f8b\uff08\u53ea\u5c55\u793a\u5173\u952e\u4ee3\u7801\uff09\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2020\/06\/carbon-1024x884.png\" alt=\"\" class=\"wp-image-187\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u7bc7\u6587\u7ae0\u6e90\u4e8e\u4e00\u4e2a\u95ee\u9898\uff1a \u5982\u4f55\u66f4\u6539\u5c3a\u5bf8\uff1f \u6211\u770b\u4e86\u53ea\u6709\u4e00\u4e2a\u56de\u7b54\uff0c\u8c8c\u4f3c\u7b54\u7684\u4e5f\u4e0d\u5bf9\uff0c\u4e0b\u9762\u8bf4\u4e00\u4e0b\u6211\u7684\u7b54\u6848\uff0c\u5176\u5b9e&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,20,3],"tags":[6],"class_list":["post-180","post","type-post","status-publish","format-standard","hentry","category-all","category-frontend","category-tech","tag-javascript"],"_links":{"self":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=180"}],"version-history":[{"count":4,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/180\/revisions"}],"predecessor-version":[{"id":428,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/180\/revisions\/428"}],"wp:attachment":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}