@neatui/nuxt 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/IMPORT_GUIDE.md +142 -0
- package/USAGE.md +32 -1
- package/package.json +3 -10
- package/src/index.ts +7 -4
package/IMPORT_GUIDE.md
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
# 组件导入指南
|
2
|
+
|
3
|
+
## 🚀 解决导入错误
|
4
|
+
|
5
|
+
如果遇到 `Module '"@neatui/nuxt"' has no exported member 'Textarea'` 错误,请使用以下方式:
|
6
|
+
|
7
|
+
### ✅ 正确的导入方式
|
8
|
+
|
9
|
+
#### 方式1: 自动导入 (推荐)
|
10
|
+
```vue
|
11
|
+
<template>
|
12
|
+
<!-- 配置模块后直接使用,无需导入 -->
|
13
|
+
<NeatTextarea v-model="content" />
|
14
|
+
<NeatInput v-model="name" />
|
15
|
+
<NeatSelect v-model="city" :options="cities" />
|
16
|
+
</template>
|
17
|
+
|
18
|
+
<script setup>
|
19
|
+
// 无需导入,组件自动可用
|
20
|
+
const content = ref('')
|
21
|
+
const name = ref('')
|
22
|
+
const city = ref('')
|
23
|
+
</script>
|
24
|
+
```
|
25
|
+
|
26
|
+
#### 方式2: 手动导入
|
27
|
+
```vue
|
28
|
+
<template>
|
29
|
+
<!-- 使用原组件名 -->
|
30
|
+
<Textarea v-model="content" />
|
31
|
+
<Input v-model="name" />
|
32
|
+
<Select v-model="city" :options="cities" />
|
33
|
+
</template>
|
34
|
+
|
35
|
+
<script setup>
|
36
|
+
// 直接从包导入,就像普通Vue组件库一样
|
37
|
+
import { Textarea, Input, Select } from '@neatui/nuxt'
|
38
|
+
|
39
|
+
const content = ref('')
|
40
|
+
const name = ref('')
|
41
|
+
const city = ref('')
|
42
|
+
</script>
|
43
|
+
```
|
44
|
+
|
45
|
+
### ❌ 错误的导入方式
|
46
|
+
|
47
|
+
```vue
|
48
|
+
<script setup>
|
49
|
+
// 🚫 错误:不能从根路径直接导入组件
|
50
|
+
import { Textarea } from '@neatui/nuxt'
|
51
|
+
|
52
|
+
// 🚫 错误:默认导入方式
|
53
|
+
import Textarea from '@neatui/nuxt'
|
54
|
+
</script>
|
55
|
+
```
|
56
|
+
|
57
|
+
## 📋 可用组件列表
|
58
|
+
|
59
|
+
### 表单组件
|
60
|
+
```js
|
61
|
+
import {
|
62
|
+
Input, // 输入框
|
63
|
+
Textarea, // 文本域
|
64
|
+
Select, // 选择器
|
65
|
+
Switch, // 开关
|
66
|
+
Checkbox, // 复选框
|
67
|
+
DatePicker, // 日期选择
|
68
|
+
DateView, // 日期显示
|
69
|
+
TimePicker, // 时间选择
|
70
|
+
Upload, // 文件上传
|
71
|
+
ImgUpload, // 图片上传
|
72
|
+
Cascader, // 级联选择
|
73
|
+
PageSelect, // 分页选择
|
74
|
+
MoreSelect, // 更多选择
|
75
|
+
SelectTags, // 标签选择
|
76
|
+
// ... 更多组件
|
77
|
+
} from '@neatui/nuxt'
|
78
|
+
```
|
79
|
+
|
80
|
+
### 加载器组件
|
81
|
+
```js
|
82
|
+
import {
|
83
|
+
FormLoader, // 表单构建器
|
84
|
+
TableLoader, // 表格加载器
|
85
|
+
ViewLoader, // 视图加载器
|
86
|
+
LimitLoader, // 限制加载器
|
87
|
+
MoveLoader, // 移动加载器
|
88
|
+
LayerLoader, // 层级加载器
|
89
|
+
} from '@neatui/nuxt'
|
90
|
+
```
|
91
|
+
|
92
|
+
### 工具组件
|
93
|
+
```js
|
94
|
+
import {
|
95
|
+
FormVerifyView, // 表单验证视图
|
96
|
+
FormDraftsView, // 表单草稿视图
|
97
|
+
MoreTools, // 更多工具
|
98
|
+
Pagination, // 分页组件
|
99
|
+
} from '@neatui/nuxt'
|
100
|
+
```
|
101
|
+
|
102
|
+
## 🔧 配置说明
|
103
|
+
|
104
|
+
### nuxt.config.ts
|
105
|
+
```ts
|
106
|
+
export default defineNuxtConfig({
|
107
|
+
modules: ['@neatui/nuxt'],
|
108
|
+
neatui: {
|
109
|
+
prefix: 'Neat', // 自动导入时的前缀
|
110
|
+
autoImport: true, // 是否启用自动导入
|
111
|
+
exclude: [] // 排除的组件
|
112
|
+
}
|
113
|
+
})
|
114
|
+
```
|
115
|
+
|
116
|
+
### package.json 导出配置
|
117
|
+
```json
|
118
|
+
{
|
119
|
+
"exports": {
|
120
|
+
".": "./src/module.ts", // Nuxt模块
|
121
|
+
"./components": "./src/index.ts" // 组件导出
|
122
|
+
}
|
123
|
+
}
|
124
|
+
```
|
125
|
+
|
126
|
+
## 💡 使用建议
|
127
|
+
|
128
|
+
1. **优先使用自动导入**: 配置模块后直接使用 `<NeatTextarea>`
|
129
|
+
2. **按需手动导入**: 只在需要时从 `/components` 导入
|
130
|
+
3. **统一命名**: 自动导入使用前缀,手动导入使用原名
|
131
|
+
4. **TypeScript支持**: 两种方式都有完整的类型提示
|
132
|
+
|
133
|
+
## 🐛 常见问题
|
134
|
+
|
135
|
+
**Q: 为什么不能直接从 '@neatui/nuxt' 导入组件?**
|
136
|
+
A: '@neatui/nuxt' 是Nuxt模块,用于配置。组件需要从 '@neatui/nuxt/components' 导入。
|
137
|
+
|
138
|
+
**Q: 自动导入的组件没有类型提示?**
|
139
|
+
A: 确保安装了 '@nuxt/kit' 依赖,并重启TypeScript服务。
|
140
|
+
|
141
|
+
**Q: 可以混合使用两种方式吗?**
|
142
|
+
A: 可以,但建议保持一致性,避免混乱。
|
package/USAGE.md
CHANGED
@@ -24,7 +24,11 @@ export default defineNuxtConfig({
|
|
24
24
|
|
25
25
|
## 🎯 基础使用
|
26
26
|
|
27
|
-
###
|
27
|
+
### 方式1: 自动导入 (推荐)
|
28
|
+
|
29
|
+
配置模块后,组件会自动注册,直接在模板中使用:
|
30
|
+
|
31
|
+
#### 表单组件
|
28
32
|
|
29
33
|
```vue
|
30
34
|
<template>
|
@@ -165,6 +169,33 @@ const formConfig = [
|
|
165
169
|
</script>
|
166
170
|
```
|
167
171
|
|
172
|
+
### 方式2: 手动导入
|
173
|
+
|
174
|
+
如果不想使用自动导入,可以直接导入组件:
|
175
|
+
|
176
|
+
```vue
|
177
|
+
<template>
|
178
|
+
<div>
|
179
|
+
<Textarea v-model="content" placeholder="请输入内容" />
|
180
|
+
<Input v-model="name" placeholder="请输入姓名" />
|
181
|
+
<Select v-model="city" :options="cities" />
|
182
|
+
</div>
|
183
|
+
</template>
|
184
|
+
|
185
|
+
<script setup>
|
186
|
+
// 直接从包导入组件
|
187
|
+
import { Textarea, Input, Select } from '@neatui/nuxt'
|
188
|
+
|
189
|
+
const content = ref('')
|
190
|
+
const name = ref('')
|
191
|
+
const city = ref('')
|
192
|
+
const cities = [
|
193
|
+
{ label: '北京', value: 'beijing' },
|
194
|
+
{ label: '上海', value: 'shanghai' }
|
195
|
+
]
|
196
|
+
</script>
|
197
|
+
```
|
198
|
+
|
168
199
|
## 🎨 主题定制
|
169
200
|
|
170
201
|
### 使用CSS变量
|
package/package.json
CHANGED
@@ -1,16 +1,9 @@
|
|
1
1
|
{
|
2
2
|
"name": "@neatui/nuxt",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.2",
|
4
4
|
"description": "NeatUI component library for Nuxt 3",
|
5
|
-
"main": "./src/
|
6
|
-
"types": "./src/
|
7
|
-
"exports": {
|
8
|
-
".": {
|
9
|
-
"types": "./src/module.ts",
|
10
|
-
"import": "./src/module.ts",
|
11
|
-
"require": "./src/module.ts"
|
12
|
-
}
|
13
|
-
},
|
5
|
+
"main": "./src/index.ts",
|
6
|
+
"types": "./src/index.ts",
|
14
7
|
"license": "MIT",
|
15
8
|
"author": "xiaojunbo",
|
16
9
|
"keywords": ["nuxt", "nuxt-module", "vue", "ui", "components"],
|
package/src/index.ts
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
-
//
|
2
|
-
export
|
3
|
-
export * from './utils/theme';
|
1
|
+
// Nuxt模块 (默认导出)
|
2
|
+
export { default } from './module'
|
4
3
|
|
5
|
-
//
|
4
|
+
// 组件导出
|
6
5
|
export * from './components/basic';
|
7
6
|
export * from './components/display';
|
8
7
|
export * from './components/form';
|
9
8
|
export * from './components/loader';
|
10
9
|
export * from './components/tools';
|
10
|
+
|
11
|
+
// 数据和工具
|
12
|
+
export * from './store/frame';
|
13
|
+
export * from './utils/theme';
|