@nhdropshipping/y-components 1.0.0 → 1.0.1
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 +43 -0
- 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 +1 -1
package/README.md
CHANGED
|
@@ -43,6 +43,9 @@ const inputValue = ref('')
|
|
|
43
43
|
|
|
44
44
|
### 使用 YMessage
|
|
45
45
|
|
|
46
|
+
YMessage 支持两种使用方式:
|
|
47
|
+
|
|
48
|
+
**方式一:直接导入使用**
|
|
46
49
|
```typescript
|
|
47
50
|
import { YMessage } from '@nhdropshipping/y-components'
|
|
48
51
|
|
|
@@ -56,6 +59,46 @@ YMessage.warning('请注意')
|
|
|
56
59
|
YMessage.error('操作失败')
|
|
57
60
|
```
|
|
58
61
|
|
|
62
|
+
**方式二:全局使用(无需 import)**
|
|
63
|
+
|
|
64
|
+
使用 `Vue.use()` 后,`YMessage` 会自动挂载到全局,可以直接使用:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
// main.ts
|
|
68
|
+
import { createApp } from 'vue'
|
|
69
|
+
import YComponents from '@nhdropshipping/y-components'
|
|
70
|
+
import '@nhdropshipping/y-components/dist/style.css'
|
|
71
|
+
|
|
72
|
+
const app = createApp(App)
|
|
73
|
+
app.use(YComponents) // 挂载后,YMessage 自动可用
|
|
74
|
+
|
|
75
|
+
// 在任何组件或文件中直接使用(无需 import)
|
|
76
|
+
YMessage.success('操作成功!')
|
|
77
|
+
YMessage.warning('请注意')
|
|
78
|
+
YMessage.error('操作失败')
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```vue
|
|
82
|
+
<template>
|
|
83
|
+
<button @click="handleClick">点击我</button>
|
|
84
|
+
</template>
|
|
85
|
+
|
|
86
|
+
<script setup lang="ts">
|
|
87
|
+
// 无需 import YMessage,直接使用
|
|
88
|
+
function handleClick() {
|
|
89
|
+
YMessage.success('操作成功!')
|
|
90
|
+
}
|
|
91
|
+
</script>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**带选项的调用:**
|
|
95
|
+
```typescript
|
|
96
|
+
YMessage.success('操作成功', {
|
|
97
|
+
duration: 3000, // 3秒后自动关闭
|
|
98
|
+
closable: true // 显示关闭按钮
|
|
99
|
+
})
|
|
100
|
+
```
|
|
101
|
+
|
|
59
102
|
## 组件列表
|
|
60
103
|
|
|
61
104
|
- **YButton** - 按钮组件
|