{"id":52599,"date":"2024-12-03T10:06:29","date_gmt":"2024-12-03T02:06:29","guid":{"rendered":"https:\/\/fwq.ai\/blog\/52599\/"},"modified":"2024-12-03T10:06:29","modified_gmt":"2024-12-03T02:06:29","slug":"vue-element-plus%e4%b8%adel-tabs%e5%88%87%e6%8d%a2echarts%e5%9b%be%e8%a1%a8%e6%97%b6%e9%a1%b5%e9%9d%a2%e8%b7%b3%e5%88%b0%e9%a1%b6%e9%83%a8%e6%80%8e%e4%b9%88%e5%8a%9e%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/52599\/","title":{"rendered":"Vue Element Plus\u4e2del-tabs\u5207\u6362ECharts\u56fe\u8868\u65f6\u9875\u9762\u8df3\u5230\u9876\u90e8\u600e\u4e48\u529e\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Vue Element Plus\u4e2del-tabs\u5207\u6362ECharts\u56fe\u8868\u65f6\u9875\u9762\u8df3\u5230\u9876\u90e8\u600e\u4e48\u529e\uff1f<\/h1>\n<p>\u54c8\u55bd\uff01\u5927\u5bb6\u597d\uff0c\u5f88\u9ad8\u5174\u53c8\u89c1\u9762\u4e86\uff0c\u6211\u662f\u7c73\u4e91\u7684\u4e00\u540d\u4f5c\u8005\uff0c\u4eca\u5929\u7531\u6211\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u7bc7<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aVue Element Plus\u4e2del-tabs\u5207\u6362ECharts\u56fe\u8868\u65f6\u9875\u9762\u8df3\u5230\u9876\u90e8\u600e\u4e48\u529e\uff1f\u300b<\/span>\uff0c\u672c\u6587\u4e3b\u8981\u4f1a\u8bb2\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u5927\u5bb6\u4e00\u8d77\u5b66\u4e60\u8fdb\u6b65\uff0c\u4e5f\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u3001\u70b9\u8d5e\u3001\u6536\u85cf\u3001\u8f6c\u53d1! \u4e0b\u9762\u5c31\u4e00\u8d77\u6765\u770b\u770b\u5427\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241121\/1732197813673f3db59ce9c.jpg\" class=\"aligncenter\" title=\"Vue Element Plus\u4e2del-tabs\u5207\u6362ECharts\u56fe\u8868\u65f6\u9875\u9762\u8df3\u5230\u9876\u90e8\u600e\u4e48\u529e\uff1f\u63d2\u56fe\" alt=\"Vue Element Plus\u4e2del-tabs\u5207\u6362ECharts\u56fe\u8868\u65f6\u9875\u9762\u8df3\u5230\u9876\u90e8\u600e\u4e48\u529e\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>el-tabs \u70b9\u51fb el-tab-pane \u5e26\u6709 v-if \u7684 echarts \u56fe\u8868\u65f6\u9875\u9762\u8df3\u81f3\u9876\u90e8<\/strong><\/p>\n<p><strong>\u95ee\u9898\u63cf\u8ff0<\/strong><\/p>\n<p>\u5728 vue elementpuls \u4e2d\u4f7f\u7528 el-tabs \u65f6\uff0cel-tab-pane \u4e2d\u5305\u542b\u4e86\u4e09\u4e2a\u4f7f\u7528 v-if \u7684 echarts \u56fe\u8868\u3002\u5f53\u70b9\u51fb\u8fd9\u4e9b\u56fe\u8868\u65f6\uff0c\u9875\u9762\u4f1a\u81ea\u52a8\u6eda\u52a8\u5230\u9876\u90e8\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p><strong>1. \u8bbe\u7f6e\u56fe\u8868\u5bb9\u5668\u7684\u9ad8\u5ea6<\/strong><\/p>\n<p>\u6709\u4e00\u79cd\u53ef\u80fd\u7684\u539f\u56e0\u662f echarts \u56fe\u8868\u7684\u5bb9\u5668\u9ad8\u5ea6\u5728 v-if \u5207\u6362\u65f6\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u5bfc\u81f4\u9875\u9762\u91cd\u65b0\u5e03\u5c40\u5e76\u8df3\u5230\u9876\u90e8\u3002\u7ed9\u56fe\u8868\u5bb9\u5668\u6dfb\u52a0\u4e00\u4e2a\u56fa\u5b9a\u9ad8\u5ea6\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>.chart-container {\n  height: 500px;\n}<\/pre>\n<p><strong>2. \u91cd\u65b0\u8003\u8651\u4f7f\u7528 v-if<\/strong><\/p>\n<p>echarts \u56fe\u8868\u5e76\u4e0d\u9700\u8981\u4f7f\u7528 v-if \u6765\u63a7\u5236\u663e\u793a\u9690\u85cf\u3002\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528 v-show\uff0c\u5e76\u5728\u5408\u9002\u7684\u65f6\u673a\u8fdb\u884c\u521d\u59cb\u5316\u6216\u8bbe\u7f6e\u9009\u9879\uff1a<\/p>\n<pre>&lt;el-tab-pane v-show=\"tab1visible\"&gt;\n  &lt;div id=\"chart1\"&gt;&lt;\/div&gt;\n&lt;\/el-tab-pane&gt;<\/pre>\n<pre>const chart1 = echarts.init(document.getElementById('chart1'));\n\nif (tab1Visible) {\n  \/\/ \u521d\u59cb\u5316\u56fe\u8868\n  chartInstance.setOption(\/* ... *\/);\n} else {\n  \/\/ \u8bbe\u7f6e\u56fe\u8868\u9009\u9879\n  chartInstance.setOption(\/* ... *\/);\n}<\/pre>\n<p>\u672c\u7bc7\u5173\u4e8e\u300aVue Element Plus\u4e2del-tabs\u5207\u6362ECharts\u56fe\u8868\u65f6\u9875\u9762\u8df3\u5230\u9876\u90e8\u600e\u4e48\u529e\uff1f\u300b\u7684\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\u5566\uff0c\u4f46\u662f\u5b66\u65e0\u6b62\u5883\uff0c\u60f3\u8981\u4e86\u89e3\u5b66\u4e60\u66f4\u591a\u5173\u4e8e\u6587\u7ae0\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   win10\u5982\u4f55\u91cd\u7f6eMicrosoft\u5e10\u6237\u5bc6\u7801\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>Vue Element Plus\u4e2del-tabs\u5207\u6362ECharts\u56fe\u8868\u65f6\u9875\u9762\u8df3\u5230\u9876\u90e8\u600e\u4e48\u529e\uff1f \u54c8\u55bd\uff01\u5927\u5bb6\u597d\uff0c\u5f88\u9ad8\u5174\u53c8\u89c1\u9762\u4e86\uff0c\u6211\u662f\u7c73\u4e91\u7684\u4e00\u540d\u4f5c\u8005\uff0c\u4eca\u5929\u7531\u6211\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u7bc7\u300aVue Element Plus\u4e2del-tabs\u5207\u6362ECharts\u56fe\u8868\u65f6\u9875\u9762\u8df3\u5230\u9876\u90e8\u600e\u4e48\u529e\uff1f\u300b\uff0c\u672c\u6587\u4e3b\u8981\u4f1a\u8bb2\u5230\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u5927\u5bb6\u4e00\u8d77\u5b66\u4e60\u8fdb\u6b65\uff0c\u4e5f\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u3001\u70b9\u8d5e\u3001\u6536\u85cf\u3001\u8f6c\u53d1! \u4e0b\u9762\u5c31\u4e00\u8d77\u6765\u770b\u770b\u5427\uff01 el-tabs \u70b9\u51fb el-tab-pane \u5e26\u6709 v-if \u7684 echarts \u56fe\u8868\u65f6\u9875\u9762\u8df3\u81f3\u9876\u90e8 \u95ee\u9898\u63cf\u8ff0 \u5728 vue elementpuls \u4e2d\u4f7f\u7528 el-tabs \u65f6\uff0cel-tab-pane \u4e2d\u5305\u542b\u4e86\u4e09\u4e2a\u4f7f\u7528 v-if \u7684 echarts \u56fe\u8868\u3002\u5f53\u70b9\u51fb\u8fd9\u4e9b\u56fe\u8868\u65f6\uff0c\u9875\u9762\u4f1a\u81ea\u52a8\u6eda\u52a8\u5230\u9876\u90e8\u3002 \u89e3\u51b3\u65b9\u6848 1. \u8bbe\u7f6e\u56fe\u8868\u5bb9\u5668\u7684\u9ad8\u5ea6 \u6709\u4e00\u79cd\u53ef\u80fd\u7684\u539f\u56e0\u662f echarts \u56fe\u8868\u7684\u5bb9\u5668\u9ad8\u5ea6\u5728 v-if \u5207\u6362\u65f6\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u5bfc\u81f4\u9875\u9762\u91cd\u65b0\u5e03\u5c40\u5e76\u8df3\u5230\u9876\u90e8\u3002\u7ed9\u56fe\u8868\u5bb9\u5668\u6dfb\u52a0\u4e00\u4e2a\u56fa\u5b9a\u9ad8\u5ea6\uff0c\u4f8b\u5982\uff1a .chart-container { height: 500px; } 2. \u91cd\u65b0\u8003\u8651\u4f7f\u7528 v-if echarts \u56fe\u8868\u5e76\u4e0d\u9700\u8981\u4f7f\u7528 v-if \u6765\u63a7\u5236\u663e\u793a\u9690\u85cf\u3002\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528 v-show\uff0c\u5e76\u5728\u5408\u9002\u7684\u65f6\u673a\u8fdb\u884c\u521d\u59cb\u5316\u6216\u8bbe\u7f6e\u9009\u9879\uff1a &lt;el-tab-pane v-show=&#8221;tab1visible&#8221;&gt; &lt;div id=&#8221;chart1&#8243;&gt;&lt;\/div&gt; &lt;\/el-tab-pane&gt; const chart1 [&hellip;]<\/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-52599","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52599","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=52599"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52599\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=52599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=52599"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=52599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}