{"id":486,"date":"2025-12-05T10:39:33","date_gmt":"2025-12-05T02:39:33","guid":{"rendered":"https:\/\/www.52runoob.com\/?p=486"},"modified":"2025-12-05T10:39:33","modified_gmt":"2025-12-05T02:39:33","slug":"vue-cli-%e6%a8%a1%e5%bc%8f%e4%b8%8b%e5%ae%89%e8%a3%85-uni-ui%e7%9a%84%e8%af%a6%e7%bb%86%e8%bf%87%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.52runoob.com\/index.php\/2025\/12\/05\/vue-cli-%e6%a8%a1%e5%bc%8f%e4%b8%8b%e5%ae%89%e8%a3%85-uni-ui%e7%9a%84%e8%af%a6%e7%bb%86%e8%bf%87%e7%a8%8b\/","title":{"rendered":"vue-cli\u00a0\u6a21\u5f0f\u4e0b\u5b89\u88c5\u00a0uni-ui\u7684\u8be6\u7ec6\u8fc7\u7a0b"},"content":{"rendered":"\n<p>\u4e0b\u9762\u7ed9\u4f60 <strong>vue-cli \u6a21\u5f0f\u4e0b\u5b89\u88c5 uni-ui \u7684\u6700\u8be6\u7ec6\u6b65\u9aa4\u6559\u7a0b\uff08\u4ece 0 \u5230\u80fd\u4f7f\u7528\uff09<\/strong>\uff0c\u65e0\u5751\u53ef\u907f\u5751\uff0c\u76f4\u63a5\u80fd\u8dd1\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\u2705 <strong>vue-cli \u6a21\u5f0f\u4e0b\u5b89\u88c5 uni-ui \u7684\u8be6\u7ec6\u8fc7\u7a0b<\/strong><\/h1>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u26a0\ufe0f <strong>\u524d\u63d0\u8bf4\u660e<\/strong>\uff1a<br>uni-ui \u867d\u7136\u662f uni-app \u5b98\u65b9 UI \u7ec4\u4ef6\u5e93\uff0c\u4f46 <strong>\u4efb\u4f55\u57fa\u4e8e Vue \u7684\u9879\u76ee\u90fd\u53ef\u4ee5\u4f7f\u7528<\/strong>\uff0c\u5305\u62ec Vue CLI\u3001Vite\u3001Nuxt \u7b49\u3002<br>\u4f46\u53ea\u6709\u5728 <strong>uni-app \u9879\u76ee<\/strong> \u4e2d\uff08HBuilderX \u6216 vue-cli \u6a21\u5f0f\uff09\u624d\u80fd\u81ea\u52a8\u9002\u914d\u5c0f\u7a0b\u5e8f\u3001H5\u3001App \u7b49\u5e73\u53f0\u3002<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udccc <strong>\u4e00\u3001\u51c6\u5907\u73af\u5883<\/strong><\/h1>\n\n\n\n<p>\u4f60\u7684\u9879\u76ee\u5e94\u5f53\u662f <strong>\u4f7f\u7528 vue-cli \u521b\u5efa\u7684 uni-app \u9879\u76ee<\/strong>\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nvue create -p dcloudio\/uni-preset-vue my-uni-app\n\n<\/pre><\/div>\n\n\n<p>\u5982\u679c\u4f60\u5df2\u7ecf\u6709\u4e00\u4e2a\u9879\u76ee\uff0c\u53ef\u8df3\u8fc7\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udccc <strong>\u4e8c\u3001\u5b89\u88c5 uni-ui\uff08\u65b9\u5f0f\u4e00\uff1anpm \u5b89\u88c5\uff09\u2014 \u63a8\u8350<\/strong><\/h1>\n\n\n\n<p>\u5728\u9879\u76ee\u6839\u76ee\u5f55\u6267\u884c\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnpm i @dcloudio\/uni-ui\n\n<\/pre><\/div>\n\n\n<p>\u6216\u4f7f\u7528 yarn\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nyarn add @dcloudio\/uni-ui\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udccc <strong>\u4e09\u3001\u81ea\u52a8\u6309\u9700\u52a0\u8f7d\uff08\u6700\u63a8\u8350\u65b9\u5f0f\uff09<\/strong><\/h1>\n\n\n\n<p>\u5b89\u88c5\u63d2\u4ef6\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnpm i -D @dcloudio\/uni-ui-nvue-styler\n\n<\/pre><\/div>\n\n\n<p>\u7136\u540e\u5728 <code>main.js<\/code> \u5f15\u5165\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nimport Vue from &#039;vue&#039;\nimport App from &#039;.\/App&#039;\n\nimport uni from &#039;@dcloudio\/uni-ui&#039;\nVue.use(uni)\n\nnew Vue({\n  ...App\n}).$mount()\n\n<\/pre><\/div>\n\n\n<p>Done\uff01<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udccc <strong>\u56db\u3001\u624b\u52a8\u6309\u9700\u5f15\u5165\u7ec4\u4ef6\uff08\u53ef\u9009\uff09<\/strong><\/h1>\n\n\n\n<p>\u6bd4\u5982\u4f7f\u7528 <code>uni-button<\/code>\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nimport uniButton from &#039;@dcloudio\/uni-ui\/lib\/uni-button\/uni-button.vue&#039;\n\nexport default {\n  components: {\n    uniButton\n  }\n}\n\n<\/pre><\/div>\n\n\n<p>\u6a21\u677f\u4e2d\u76f4\u63a5\u4f7f\u7528\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;uni-button type=&quot;primary&quot;&gt;\u6309\u94ae&amp;lt;\/uni-button&gt;\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udccc <strong>\u4e94\u3001\u652f\u6301\u81ea\u52a8\u7ec4\u4ef6\u626b\u63cf\uff08uni-app \u5185\u7f6e\u529f\u80fd\uff09<\/strong><\/h1>\n\n\n\n<p>uni-ui \u5c5e\u4e8e\u5b98\u65b9\u7ec4\u4ef6\uff0c<strong>\u4e0d\u9700\u8981\u989d\u5916\u914d\u7f6e\u63d2\u4ef6<\/strong>\uff0c\u7f16\u8bd1\u5668\u4f1a\u81ea\u52a8\u8bc6\u522b\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\u4f60\u5728\u9875\u9762\u4e2d\u76f4\u63a5\u5199\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;template&gt;\n  &amp;lt;view&gt;\n    &amp;lt;uni-card title=&quot;\u6807\u9898&quot; extra=&quot;\u66f4\u591a&quot;&gt;\n      \u5185\u5bb9\u5185\u5bb9\u5185\u5bb9\n    &amp;lt;\/uni-card&gt;\n  &amp;lt;\/view&gt;\n&amp;lt;\/template&gt;\n\n<\/pre><\/div>\n\n\n<p><strong>\u4e0d\u9700\u8981 import\uff0c\u7f16\u8bd1\u5668\u4f1a\u76f4\u63a5\u5e2e\u4f60\u5f15\u5165<\/strong>\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udccc <strong>\u516d\u3001HBuilderX \u4e0e vue-cli \u533a\u522b\uff08\u91cd\u70b9\uff09<\/strong><\/h1>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u529f\u80fd<\/th><th>vue-cli \u6a21\u5f0f<\/th><th>HBuilderX \u6a21\u5f0f<\/th><\/tr><\/thead><tbody><tr><td>uni-ui \u5f15\u5165\u65b9\u5f0f<\/td><td>\u9700\u8981\u5b89\u88c5 npm \u5305<\/td><td>\u6253\u5f00\u63d2\u4ef6\u5373\u53ef<\/td><\/tr><tr><td>\u662f\u5426\u81ea\u52a8\u6309\u9700\u5f15\u5165<\/td><td>\u2714\ufe0f \u652f\u6301<\/td><td>\u2714\ufe0f \u5185\u7f6e<\/td><\/tr><tr><td>\u9700\u4e0d\u9700\u8981 import<\/td><td>\u4e0d\u9700\u8981\uff08\u7f16\u8bd1\u5668\u81ea\u52a8\u5904\u7406\uff09<\/td><td>\u4e0d\u9700\u8981<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udccc <strong>\u4e03\u3001\u6d4b\u8bd5\u662f\u5426\u5b89\u88c5\u6210\u529f<\/strong><\/h1>\n\n\n\n<p>\u968f\u4fbf\u521b\u5efa\u4e00\u4e2a\u9875\u9762\uff1a<code>pages\/index\/index.vue<\/code><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;template&gt;\n  &amp;lt;view class=&quot;content&quot;&gt;\n    &amp;lt;uni-section title=&quot;\u6d4b\u8bd5 uni-ui&quot; sub-title=&quot;\u8fd9\u662f\u7b2c\u4e00\u6bb5&quot; type=&quot;line&quot;&gt;&amp;lt;\/uni-section&gt;\n\n    &amp;lt;uni-card title=&quot;\u5361\u7247\u6807\u9898&quot; extra=&quot;\u66f4\u591a&quot;&gt;\n      Hello uni-ui\uff01\n    &amp;lt;\/uni-card&gt;\n\n    &amp;lt;uni-button type=&quot;primary&quot;&gt;\u4e3b\u6309\u94ae&amp;lt;\/uni-button&gt;\n  &amp;lt;\/view&gt;\n&amp;lt;\/template&gt;\n\n<\/pre><\/div>\n\n\n<p>\u8fd0\u884c\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnpm run dev:%PLATFORM%\n\n<\/pre><\/div>\n\n\n<p>\u4f8b\u5982\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnpm run dev:mp-weixin\nnpm run dev:h5\n\n<\/pre><\/div>\n\n\n<p>\u770b\u5230\u7ec4\u4ef6\u6b63\u5e38\u663e\u793a\uff0c\u5373\u6210\u529f\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udccc <strong>\u516b\u3001\u5e38\u89c1\u95ee\u9898\uff08\u5fc5\u770b\uff09<\/strong><\/h1>\n\n\n\n<h3 class=\"wp-block-heading\">\u27571. \u63d0\u793a\u7ec4\u4ef6\u672a\u627e\u5230<\/h3>\n\n\n\n<p>\u539f\u56e0\uff1a\u6ca1\u6709\u5b89\u88c5 <code>@dcloudio\/uni-ui<\/code><br>\u89e3\u51b3\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnpm i @dcloudio\/uni-ui\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u27572. \u5c0f\u7a0b\u5e8f\u7aef\u62a5 \u201cComponent is not found\u201d<\/h3>\n\n\n\n<p>\u8bf7\u68c0\u67e5\uff1a<br><code>pages.json<\/code> \u662f\u5426\u6b63\u786e\u914d\u7f6e\u9875\u9762\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u27573. \u4f7f\u7528 nvue \u65f6\u6837\u5f0f\u4e0d\u751f\u6548<\/h3>\n\n\n\n<p>\u6267\u884c\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnpm i -D @dcloudio\/uni-ui-nvue-styler\n\n<\/pre><\/div>\n\n\n<p>\u5e76\u91cd\u542f\u9879\u76ee\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udccc <strong>\u4e5d\u3001\u5b8c\u6574\u793a\u4f8b Demo<\/strong><\/h1>\n\n\n\n<p>\u7ed9\u4f60\u4e00\u4e2a\u6700\u5c0f\u53ef\u8fd0\u884c\u793a\u4f8b\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;template&gt;\n  &amp;lt;view&gt;\n    &amp;lt;uni-card title=&quot;\u6b22\u8fce&quot; extra=&quot;\u66f4\u591a&quot;&gt;\n      uni-ui \u5728 vue-cli \u6a21\u5f0f\u6210\u529f\u8fd0\u884c\uff01\n    &amp;lt;\/uni-card&gt;\n\n    &amp;lt;uni-button type=&quot;primary&quot; @click=&quot;handleClick&quot;&gt;\n      \u70b9\u51fb\u6d4b\u8bd5\n    &amp;lt;\/uni-button&gt;\n  &amp;lt;\/view&gt;\n&amp;lt;\/template&gt;\n\n&amp;lt;script&gt;\nexport default {\n  methods: {\n    handleClick() {\n      uni.showToast({\n        title: &quot;\u6210\u529f&quot;,\n        icon: &quot;success&quot;\n      })\n    }\n  }\n}\n&amp;lt;\/script&gt;\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83c\udf89 <strong>\u603b\u7ed3<\/strong><\/h1>\n\n\n\n<p>\u4f60\u53ea\u9700\u8981\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><code>npm install @dcloudio\/uni-ui<\/code><\/li>\n\n\n\n<li>\u5728\u9875\u9762\u4e2d\u76f4\u63a5\u4f7f\u7528 <code>&lt;uni-xxx><\/code> \u6807\u7b7e<\/li>\n<\/ol>\n\n\n\n<p>\u5c31\u80fd\u5728 <strong>vue-cli \u6a21\u5f0f\u7684 uni-app \u4e2d\u4f7f\u7528\u5168\u90e8 uni-ui \u7ec4\u4ef6<\/strong>\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u9762\u7ed9\u4f60 vue-cli \u6a21\u5f0f\u4e0b\u5b89\u88c5 uni-ui \u7684\u6700\u8be6\u7ec6\u6b65\u9aa4\u6559\u7a0b\uff08\u4ece 0 \u5230&#8230; <a class=\"more-link\" href=\"https:\/\/www.52runoob.com\/index.php\/2025\/12\/05\/vue-cli-%e6%a8%a1%e5%bc%8f%e4%b8%8b%e5%ae%89%e8%a3%85-uni-ui%e7%9a%84%e8%af%a6%e7%bb%86%e8%bf%87%e7%a8%8b\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[],"class_list":["post-486","post","type-post","status-publish","format-standard","hentry","category-javascript"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/comments?post=486"}],"version-history":[{"count":1,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/486\/revisions"}],"predecessor-version":[{"id":487,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/486\/revisions\/487"}],"wp:attachment":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/media?parent=486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/categories?post=486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/tags?post=486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}