@nhdropshipping/y-components 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +495 -494
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -14,12 +14,20 @@ pnpm add @nhdropshipping/y-components
|
|
|
14
14
|
|
|
15
15
|
## 使用
|
|
16
16
|
|
|
17
|
+
### ⚠️ 重要提示
|
|
18
|
+
|
|
19
|
+
**使用组件库前,必须先引入样式文件!**
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import '@nhdropshipping/y-components/dist/style.css'
|
|
23
|
+
```
|
|
24
|
+
|
|
17
25
|
### 全量引入
|
|
18
26
|
|
|
19
27
|
```typescript
|
|
20
28
|
import { createApp } from 'vue'
|
|
21
29
|
import YComponents from '@nhdropshipping/y-components'
|
|
22
|
-
import '@nhdropshipping/y-components/dist/style.css' //
|
|
30
|
+
import '@nhdropshipping/y-components/dist/style.css' // ⚠️ 必须引入样式文件
|
|
23
31
|
|
|
24
32
|
const app = createApp(App)
|
|
25
33
|
app.use(YComponents)
|
|
@@ -35,6 +43,7 @@ app.use(YComponents)
|
|
|
35
43
|
|
|
36
44
|
<script setup lang="ts">
|
|
37
45
|
import { YButton, YInput } from '@nhdropshipping/y-components'
|
|
46
|
+
import '@nhdropshipping/y-components/dist/style.css' // ⚠️ 必须引入样式文件
|
|
38
47
|
import { ref } from 'vue'
|
|
39
48
|
|
|
40
49
|
const inputValue = ref('')
|
|
@@ -43,6 +52,9 @@ const inputValue = ref('')
|
|
|
43
52
|
|
|
44
53
|
### 使用 YMessage
|
|
45
54
|
|
|
55
|
+
YMessage 支持两种使用方式:
|
|
56
|
+
|
|
57
|
+
**方式一:直接导入使用**
|
|
46
58
|
```typescript
|
|
47
59
|
import { YMessage } from '@nhdropshipping/y-components'
|
|
48
60
|
|
|
@@ -56,6 +68,46 @@ YMessage.warning('请注意')
|
|
|
56
68
|
YMessage.error('操作失败')
|
|
57
69
|
```
|
|
58
70
|
|
|
71
|
+
**方式二:全局使用(无需 import)**
|
|
72
|
+
|
|
73
|
+
使用 `Vue.use()` 后,`YMessage` 会自动挂载到全局,可以直接使用:
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
// main.ts
|
|
77
|
+
import { createApp } from 'vue'
|
|
78
|
+
import YComponents from '@nhdropshipping/y-components'
|
|
79
|
+
import '@nhdropshipping/y-components/dist/style.css' // ⚠️ 必须引入样式文件
|
|
80
|
+
|
|
81
|
+
const app = createApp(App)
|
|
82
|
+
app.use(YComponents) // 挂载后,YMessage 自动可用
|
|
83
|
+
|
|
84
|
+
// 在任何组件或文件中直接使用(无需 import)
|
|
85
|
+
YMessage.success('操作成功!')
|
|
86
|
+
YMessage.warning('请注意')
|
|
87
|
+
YMessage.error('操作失败')
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```vue
|
|
91
|
+
<template>
|
|
92
|
+
<button @click="handleClick">点击我</button>
|
|
93
|
+
</template>
|
|
94
|
+
|
|
95
|
+
<script setup lang="ts">
|
|
96
|
+
// 无需 import YMessage,直接使用
|
|
97
|
+
function handleClick() {
|
|
98
|
+
YMessage.success('操作成功!')
|
|
99
|
+
}
|
|
100
|
+
</script>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**带选项的调用:**
|
|
104
|
+
```typescript
|
|
105
|
+
YMessage.success('操作成功', {
|
|
106
|
+
duration: 3000, // 3秒后自动关闭
|
|
107
|
+
closable: true // 显示关闭按钮
|
|
108
|
+
})
|
|
109
|
+
```
|
|
110
|
+
|
|
59
111
|
## 组件列表
|
|
60
112
|
|
|
61
113
|
- **YButton** - 按钮组件
|