File tree Expand file tree Collapse file tree 4 files changed +78
-8
lines changed Expand file tree Collapse file tree 4 files changed +78
-8
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,10 @@ exports.createVitepressSidebarTemplates = (componentsInfo = []) => {
5454 text : '快速开始' ,
5555 link : '/quick-start/' ,
5656 } ,
57+ {
58+ text : '按需引入' ,
59+ link : '/on-demand/' ,
60+ } ,
5761 {
5862 text : '主题定制' ,
5963 link : '/theme-guide/' ,
@@ -68,6 +72,10 @@ exports.createVitepressSidebarTemplates = (componentsInfo = []) => {
6872 text : 'Quick Start' ,
6973 link : '/en-US/quick-start/' ,
7074 } ,
75+ {
76+ text : 'On-demand Import' ,
77+ link : '/on-demand/' ,
78+ } ,
7179 {
7280 text : 'Theme Guide' ,
7381 link : '/theme-guide/' ,
Original file line number Diff line number Diff line change 1+ # 按需引入
2+
3+ 除了全量引入,我们也支持单个组件按需引入。
4+
5+ ### 自动引入
6+
7+ 配置` unplugin-vue-components ` 插件可以无需引入Vue DevUI就可以直接按需使用其中的组件,具体使用方式如下:
8+
9+ - 安装` unplugin-vue-components ` 插件
10+
11+ ``` shell
12+ npm i -D unplugin-vue-components
13+ ```
14+
15+ - 在` vite.config.ts ` 文件中添加以下代码:
16+
17+ ``` ts
18+ import Components from ' unplugin-vue-components/vite'
19+ import { DevUiResolver } from ' unplugin-vue-components/resolvers'
20+ export default defineConfig ({
21+ plugins: [
22+ vue (),
23+ // 新增
24+ Components ({
25+ resolvers: [
26+ DevUiResolver ()
27+ ]
28+ })
29+ ]
30+ })
31+ ```
32+
33+ 配置了以上插件,就可以直接在代码中使用` Vue DevUI ` 的组件,而无需在` main.ts ` 文件中引入` Vue DevUI ` 。
34+
35+ ## 手动引入
36+
37+ 在` src/main.ts ` 文件中写入以下内容:
38+
39+ ``` ts
40+ import Button from ' vue-devui/button' ;
41+ import ' vue-devui/button/style.css' ;
42+
43+ createApp (App ).use (Button ).mount (' #app' );
44+ ```
45+
46+ 在` src/App.vue ` 文件的` <template> ` 中增加以下内容:
47+
48+ ``` vue
49+ <template>
50+ <!-- 使用 Button 组件 -->
51+ <d-button>确定</d-button>
52+ </template>
53+ ```
Original file line number Diff line number Diff line change @@ -20,21 +20,22 @@ npm create vite my-vue-app -- --template vue-ts
2020
2121### 2. 安装
2222
23- 进入你的项目文件夹,使用 NPM 安装` Vue DevUI `
23+ 进入你的项目文件夹,使用 NPM 安装` Vue DevUI ` 和配套的图标库
2424
2525``` shell
26- npm i vue-devui
26+ npm i vue-devui @devui-design/icons
2727```
2828
2929### 3. 引入插件和样式
3030
3131在` src/main.ts ` 文件中写入以下内容
3232
3333``` ts
34- import DevUI from ' vue-devui'
35- import ' vue-devui/style.css'
34+ import DevUI from ' vue-devui' ;
35+ import ' vue-devui/style.css' ;
36+ import ' @devui-design/icons/icomoon/devui-icon.css' ;
3637
37- createApp (App ).use (DevUI ).mount (' #app' )
38+ createApp (App ).use (DevUI ).mount (' #app' );
3839```
3940
4041### 4. 使用
@@ -52,4 +53,12 @@ createApp(App).use(DevUI).mount('#app')
5253
5354``` shell
5455npm run dev
55- ```
56+ ```
57+
58+ ### 6 按需引入
59+
60+ 参考:[ 按需引入] ( /on-demand/ )
61+
62+ ### 7 主题定制
63+
64+ 参考:[ 主题定制] ( /theme-guide/ )
Original file line number Diff line number Diff line change 66
77内置主题:
88
9- - 浅色主题` devuiLightTheme ` (默认主题, ` DevUI蓝 ` 主题)
9+ - 浅色主题` devuiLightTheme `
1010- 深色主题` devuiDarkTheme `
1111- 绿色主题` devuiGreenTheme `
1212- 绿色深色主题` devuiGreenDarkTheme `
1313
1414扩展主题:
1515
16- - 无限主题` infinityTheme `
16+ - 无限主题` infinityTheme ` (默认主题)
1717- 紫罗兰主题` provenceTheme `
1818- 蜜糖主题` sweetTheme `
1919- 深邃夜空主题` deepTheme `
You can’t perform that action at this time.
0 commit comments