Skip to content

Commit f442c00

Browse files
committed
docs: add documentation on how to use vue-devui in nuxt3 projects
1 parent 67ce874 commit f442c00

File tree

4 files changed

+173
-150
lines changed

4 files changed

+173
-150
lines changed

packages/devui-vue/devui-cli/templates/vitepress-sidebar.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ exports.createVitepressSidebarTemplates = (componentsInfo = []) => {
6565
text: '主题定制',
6666
link: '/theme-guide/',
6767
},
68+
{
69+
text: '在 Nuxt3 中使用',
70+
link: '/nuxt3/',
71+
},
6872
],
6973
handler: generateZhMenus,
7074
lang: 'zh',

packages/devui-vue/docs/components/message/index.md

Lines changed: 74 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -15,71 +15,70 @@
1515
```vue
1616
<template>
1717
<div class="demo-spacing">
18-
<d-button @click="open('normal')">normal</d-button>
19-
<d-button @click="open('success')">success</d-button>
20-
<d-button @click="open('error')">error</d-button>
21-
<d-button @click="open('warning')">warning</d-button>
22-
<d-button @click="open('info')">info</d-button>
23-
</div>
18+
<d-button @click="open('normal')">normal</d-button>
19+
<d-button @click="open('success')">success</d-button>
20+
<d-button @click="open('error')">error</d-button>
21+
<d-button @click="open('warning')">warning</d-button>
22+
<d-button @click="open('info')">info</d-button>
23+
</div>
2424
</template>
2525
<script>
2626
import { defineComponent } from 'vue';
2727
2828
export default defineComponent({
2929
setup() {
30-
31-
function open (type) {
30+
function open(type) {
3231
this.$message({
3332
type,
34-
message: 'this is a message.'
35-
})
33+
message: 'this is a message.',
34+
});
3635
}
37-
36+
3837
return { open };
39-
}
38+
},
4039
});
4140
</script>
4241
```
42+
4343
:::
4444

4545
### 可关闭消息提示
4646

47-
默认的 Message 是不可以被人工关闭的。 如果你需要手动关闭功能,你可以把 `showClose` 设置为 `true` 此外,默认的关闭时间为 3000 毫秒,当把这个属性(`duration`的值设置为0便表示该消息不会被自动关闭
47+
默认的 Message 是不可以被人工关闭的。 如果你需要手动关闭功能,你可以把 `showClose` 设置为 `true` 此外,默认的关闭时间为 3000 毫秒,当把这个属性(`duration`的值设置为 0 便表示该消息不会被自动关闭
4848

4949
:::demo
5050

5151
```vue
5252
<template>
5353
<div class="demo-spacing">
54-
<d-button @click="closeIcon()">show close icon</d-button>
55-
<d-button @click="notClose()">not close</d-button>
56-
</div>
54+
<d-button @click="closeIcon()">show close icon</d-button>
55+
<d-button @click="notClose()">not close</d-button>
56+
</div>
5757
</template>
5858
<script>
5959
import { defineComponent } from 'vue';
6060
6161
export default defineComponent({
6262
setup() {
63-
64-
function closeIcon () {
63+
function closeIcon() {
6564
this.$message({
66-
type:'success',
67-
message:'Show close button.',
65+
type: 'success',
66+
message: 'Show close button.',
6867
showClose: true,
6968
});
7069
}
7170
72-
function notClose () {
71+
function notClose() {
7372
this.$message({
74-
type:'info',
75-
message:'Do not automatically close messages.',
73+
type: 'info',
74+
message: 'Do not automatically close messages.',
7675
showClose: true,
77-
duration: 0
76+
duration: 0,
7877
});
7978
}
80-
79+
8180
return { closeIcon, notClose };
82-
}
81+
},
8382
});
8483
</script>
8584
```
@@ -88,38 +87,36 @@ export default defineComponent({
8887

8988
### 超时时间
9089

91-
通过设置`duration`来规定`message`所显示的时间以毫秒来规定(1000毫秒 => 1秒),将这个属性设置为0则不会自动关闭
90+
通过设置`duration`来规定`message`所显示的时间以毫秒来规定(1000 毫秒 => 1 秒),将这个属性设置为 0 则不会自动关闭
9291

9392
:::demo
9493

9594
```vue
9695
<template>
9796
<div class="demo-spacing">
98-
<d-button @click="open()">show message 5000ms</d-button>
99-
</div>
97+
<d-button @click="open()">show message 5000ms</d-button>
98+
</div>
10099
</template>
101100
<script>
102101
import { defineComponent } from 'vue';
103102
104103
export default defineComponent({
105104
setup() {
106-
107-
function open () {
105+
function open() {
108106
this.$message({
109-
type:'success',
110-
message:'show message 5000ms.',
107+
type: 'success',
108+
message: 'show message 5000ms.',
111109
duration: 5000,
112110
showClose: true,
113111
});
114112
}
115-
113+
116114
return { open };
117-
}
115+
},
118116
});
119117
</script>
120118
```
121119

122-
123120
:::
124121

125122
### 阴影和边框设置
@@ -133,44 +130,43 @@ export default defineComponent({
133130
```vue
134131
<template>
135132
<div class="demo-spacing">
136-
<d-button @click="closeBordered()">close bordered</d-button>
137-
<d-button @click="closeShadow()">close shadow</d-button>
138-
<d-button @click="closeBAndS()">close bordered And shadow</d-button>
139-
</div>
133+
<d-button @click="closeBordered()">close bordered</d-button>
134+
<d-button @click="closeShadow()">close shadow</d-button>
135+
<d-button @click="closeBAndS()">close bordered And shadow</d-button>
136+
</div>
140137
</template>
141138
<script>
142139
import { defineComponent } from 'vue';
143140
144141
export default defineComponent({
145142
setup() {
146-
147-
function closeBordered () {
143+
function closeBordered() {
148144
this.$message({
149-
type:'success',
150-
message:'close bordered.',
145+
type: 'success',
146+
message: 'close bordered.',
151147
bordered: false,
152148
});
153149
}
154150
155-
function closeShadow () {
151+
function closeShadow() {
156152
this.$message({
157-
type:'info',
158-
message:'close shadow.',
153+
type: 'info',
154+
message: 'close shadow.',
159155
shadow: false,
160156
});
161157
}
162158
163-
function closeBAndS () {
159+
function closeBAndS() {
164160
this.$message({
165-
type:'error',
166-
message:'close shadow.',
161+
type: 'error',
162+
message: 'close shadow.',
167163
bordered: false,
168164
shadow: false,
169165
});
170166
}
171-
167+
172168
return { closeBordered, closeShadow, closeBAndS };
173-
}
169+
},
174170
});
175171
</script>
176172
```
@@ -179,87 +175,88 @@ export default defineComponent({
179175

180176
### 关闭回调
181177

182-
通过onClose参数设置消息关闭时的回调
178+
通过 onClose 参数设置消息关闭时的回调
183179
:::demo
184180

185181
```vue
186182
<template>
187183
<div class="demo-spacing">
188-
<d-button @click="closeMessage()">close message</d-button>
189-
</div>
184+
<d-button @click="closeMessage()">close message</d-button>
185+
</div>
190186
</template>
191187
<script>
192188
import { defineComponent } from 'vue';
193189
194190
export default defineComponent({
195191
setup() {
196-
197-
function closeMessage () {
192+
function closeMessage() {
198193
this.$message({
199-
type:'success',
200-
message:'close message.',
194+
type: 'success',
195+
message: 'close message.',
201196
onClose: () => {
202197
console.log('message closed');
203198
},
204199
});
205200
}
206-
201+
207202
return { closeMessage };
208-
}
203+
},
209204
});
210205
</script>
211206
```
212207

213208
:::
214209

215210
### 多种用法
216-
调用message 消息的时候可以有多种调用方法和多种使用方式。
211+
212+
调用 message 消息的时候可以有多种调用方法和多种使用方式。
217213

218214
##### 调用方式
215+
219216
```javascript
220217
// 第一种 全局调用
221218
this.$message('I call message globally');
222219

223220
// 第二种 引入局部调用
224-
import { message } from 'vue-devui'
225-
message('I call message locally')
221+
import { Message } from 'vue-devui';
222+
message('I call message locally');
226223
```
227224

228225
##### 使用方式
226+
229227
```javascript
230-
import { message } from 'vue-devui'
228+
import { Message } from 'vue-devui';
231229

232230
// 传入字符串直接使用默认参数
233231
message('I am a default message');
234232

235233
// 传入对象设置参数
236234
message({
237-
message:'I am message',
235+
message: 'I am message',
238236
type: 'info',
239237
bordered: false,
240238
});
241239

242240
// 直接选择类型调用
243241
message.error('I am a error message');
244242
message.error({
245-
message:'I am a error message',
243+
message: 'I am a error message',
246244
bordered: false,
247245
shadow: false,
248246
});
249247
```
250248

251249
### Message 参数
252250

253-
| 参数名 | 类型 | 默认 | 说明 | 跳转 |
254-
| :------- | :----------------- | :------- | :------------------------- | :---------------------------- |
255-
| message | `string` | '' | 设置消息文字 | [基础用法](#基础用法) |
256-
| type | `MessageType` | 'normal'| 设置消息内容类型 | [基础用法](#基础用法) |
257-
| showClose | `Boolean`| false | 设置展示可关闭按钮 | [可关闭消息提示](#可关闭消息提示) |
258-
| duration | `number`| 3000 | 设置超时时间 | [超时时间](#超时时间) |
259-
| shadow | `Boolean`| true | 设置是否展示阴影 | [阴影和边框设置](#阴影和边框设置) |
260-
| bordered | `Boolean`| true | 设置是否展示边框 | [阴影和边框设置](#阴影和边框设置) |
261-
| on-close | `() => void` | - | 设置消息关闭时的回调 | [关闭回调](#关闭回调) |
262-
251+
| 参数名 | 类型 | 默认 | 说明 | 跳转 |
252+
| :-------- | :------------ | :------- | :------------------- | :-------------------------------- |
253+
| message | `string` | '' | 设置消息文字 | [基础用法](#基础用法) |
254+
| type | `MessageType` | 'normal' | 设置消息内容类型 | [基础用法](#基础用法) |
255+
| showClose | `Boolean` | false | 设置展示可关闭按钮 | [可关闭消息提示](#可关闭消息提示) |
256+
| duration | `number` | 3000 | 设置超时时间 | [超时时间](#超时时间) |
257+
| shadow | `Boolean` | true | 设置是否展示阴影 | [阴影和边框设置](#阴影和边框设置) |
258+
| bordered | `Boolean` | true | 设置是否展示边框 | [阴影和边框设置](#阴影和边框设置) |
259+
| on-close | `() => void` | - | 设置消息关闭时的回调 | [关闭回调](#关闭回调) |
263260

264261
### Message 类型定义
265262

0 commit comments

Comments
 (0)