Appearance
Button 按钮
这是 Button
基础例子
vue
<script setup lang="ts">
</script>
<template>
<div>
<NpButton>
默认按钮
</NpButton>
<np-button type="info">
info
</np-button>
<np-button type="primary">
primary
</np-button>
<np-button type="success">
success
</np-button>
<np-button type="warning">
warning
</np-button>
<np-button type="danger">
danger
</np-button>
</div>
<div style="margin: 20px 0;">
<NpButton plain>
默认按钮
</NpButton>
<np-button type="info" plain>
info
</np-button>
<np-button type="primary" plain>
primary
</np-button>
<np-button type="success" plain>
success
</np-button>
<np-button type="warning" plain>
warning
</np-button>
<np-button type="danger" plain>
danger
</np-button>
</div>
<div>
<NpButton round>
默认按钮
</NpButton>
<np-button type="info" round>
info
</np-button>
<np-button type="primary" round>
primary
</np-button>
<np-button type="success" round>
success
</np-button>
<np-button type="warning" round>
warning
</np-button>
<np-button type="danger" round>
danger
</np-button>
</div>
<div style="margin: 20px 0;">
<NpButton icon="search" size="small" circle />
<np-button icon="search" type="info" size="small" circle />
<np-button icon="search" type="primary" circle plain />
<np-button icon="search" type="success" circle plain />
<np-button icon="search" type="warning" size="large" circle />
<np-button icon="search" type="danger" size="large" circle />
</div>
</template>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
禁用方式:disabled
设置为 true
vue
<script setup lang="ts">
</script>
<template>
<div>
<NpButton disabled>
默认按钮
</NpButton>
<np-button disabled type="info">
info
</np-button>
<np-button disabled type="primary">
primary
</np-button>
<np-button disabled type="success">
success
</np-button>
<np-button disabled type="warning">
warning
</np-button>
<np-button disabled type="danger">
danger
</np-button>
</div>
<div style="margin: 20px 0;">
<NpButton disabled plain>
默认按钮
</NpButton>
<np-button disabled type="info" plain>
info
</np-button>
<np-button disabled type="primary" plain>
primary
</np-button>
<np-button disabled type="success" plain>
success
</np-button>
<np-button disabled type="warning" plain>
warning
</np-button>
<np-button disabled type="danger" plain>
danger
</np-button>
</div>
</template>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
使用方式:size
可选值 default
small
large
vue
<script setup lang="ts">
</script>
<template>
<div style="display: inline-flex;gap: 10px">
<np-button size="large">
large
</np-button>
<np-button size="default" type="primary">
普通
</np-button>
<np-button size="small">
small
</np-button>
</div>
</template>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
使用方式:size
可选值 default
small
large
vue
<script setup lang="ts">
import { Notice } from 'npc-ui'
import { h } from 'vue'
import { IconAlarm } from '@npc-ui/icons'
function handleClick() {
const Icon = h(IconAlarm, { style: { color: 'red', marginRight: 4 } })
const style = { display: 'flex', alignItems: 'center' }
Notice.info({
title: h('span', { style }, [Icon, '提示']),
content: '正在提交...',
})
}
</script>
<template>
<div style="display: inline-flex;gap: 10px">
<np-button spin icon="shopping">
图标按钮
</np-button>
<np-button icon="search" type="primary" plain>
图标按钮
</np-button>
<np-button icon="search" type="primary">
图标按钮
</np-button>
<np-button @click="handleClick">
Loading...
</np-button>
<np-button disabled spin loading @click="handleClick">
Loading...
</np-button>
</div>
</template>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
属性说明
属性 | 属性描述 | 类型 | 默认值 |
---|---|---|---|
type | 按钮类型 | info | primary | success | warning | danger | 空 |
nativeType | 原生属性 | submit | reset | button | 空 |
size | 按钮大小 | default | small | large | 空 |
plain | 空心 | boolean | false |
round | 圆边 | boolean | false |
circle | 正圆 | boolean | false |
loading | 加载图标 | boolean | false |
disable | 禁用状态 | boolean | false |
autofocus | 自动聚焦 | boolean | false |
icon | 图标名称 | string | -- |
事件说明
事件 | 事件描述 | 类型 |
---|---|---|
click | 点击触发 | (ev:Event) => void |