Skip to content

Commit d22201e

Browse files
committed
docs(docs): 更新文档 添加naiveUi支持
1 parent b36c367 commit d22201e

File tree

4 files changed

+42
-31
lines changed

4 files changed

+42
-31
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"scripts": {
1313
"docs:dev": "yarn workspace docs dev",
1414
"docs:build": "yarn workspace docs build",
15-
"lib:build": "yarn lib-element:build && yarn lib-iview3:build && yarn lib3-element:build && yarn lib3-ant:build",
15+
"lib:build": "yarn lib-element:build && yarn lib-iview3:build && yarn lib3-element:build && yarn lib3-ant:build && yarn lib3-naive:build",
1616
"lib-element:watch": "yarn workspace @lljj/vue-json-schema-form watch",
1717
"lib-element:build": "yarn workspace @lljj/vue-json-schema-form build",
1818
"lib-iview3:watch": "yarn workspace @lljj/vue2-form-iview3 watch",
@@ -21,6 +21,7 @@
2121
"lib3-element:build": "yarn workspace @lljj/vue3-form-element build",
2222
"lib3-ant:watch": "yarn workspace @lljj/vue3-form-ant watch",
2323
"lib3-ant:build": "yarn workspace @lljj/vue3-form-ant build",
24+
"lib3-naive:build": "yarn workspace @lljj/vue3-form-naive build",
2425
"demo:dev": "yarn workspace demo dev",
2526
"demo:build": "yarn workspace demo build",
2627
"demo3:dev": "yarn workspace demo-v3 dev",

packages/demo/demo-v3/src/pages/index/views/Demo/index.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,14 @@ import EditorHeader from 'demo-common/components/EditorHeader.vue';
225225
import CodeEditor from 'demo-common/components/CodeEditor';
226226
import schemaTypes from 'demo-common/schemaTypes';
227227
228-
const VueElementForm = defineAsyncComponent(() => import('@lljj/vue3-form-element/src/index'));
228+
const VueElementForm = defineAsyncComponent(() => import('@lljj/vue3-form-element'));
229229
230230
let installedAntdv = false;
231231
const VueAntForm = defineAsyncComponent(async () => {
232232
// eslint-disable-next-line no-unused-vars
233233
const [antdv, antForm] = await Promise.all([
234234
import('demo-common/components/Antdv/index.js'),
235-
import('@lljj/vue3-form-ant/src/index')
235+
import('@lljj/vue3-form-ant')
236236
]);
237237
238238
return {
@@ -252,21 +252,22 @@ const VueAntForm = defineAsyncComponent(async () => {
252252
};
253253
});
254254
255+
let installedNaive = false;
255256
const VueNaiveForm = defineAsyncComponent(async () => {
256257
// eslint-disable-next-line no-unused-vars
257258
const [naive, antForm] = await Promise.all([
258259
import('demo-common/components/Naive/index.js'),
259-
import('@lljj/vue3-form-naive/src/index')
260+
import('@lljj/vue3-form-naive')
260261
]);
261262
262263
return {
263264
name: 'naiveFormWrap',
264265
setup(props, { attrs, slots }) {
265-
// hack 动态install antDv,因为我不知其它地方如何获取 vue app
266-
if (!installedAntdv) {
266+
// hack 动态install naive,因为我不知其它地方如何获取 vue app
267+
if (!installedNaive) {
267268
const instance = getCurrentInstance();
268269
instance.appContext.app.use(naive.default);
269-
installedAntdv = true;
270+
installedNaive = true;
270271
}
271272
272273
return () => h(antForm.default, {
@@ -296,7 +297,7 @@ export default {
296297
name: 'ElementPlus',
297298
component: 'VueElementForm'
298299
}, {
299-
name: 'antdv',
300+
name: 'Antdv',
300301
component: 'VueAntForm'
301302
}, {
302303
name: 'Naive',

packages/docs/docs/zh/guide/README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
* umd script 标签形式引入暴露全局变量 `window.vue3FormElement``window.vue3FormElement.default` 暴露组件
3939
* [playground](https://form.lljj.me/v3/#/demo?type=Simple)
4040

41+
### @lljj/vue3-form-naive
42+
* 适配ui库:`Vue3` `antdv`
43+
* package name : `@lljj/vue3-form-naive`
44+
* umd cdn地址:[@lljj/vue3-form-naive cdn](https://cdn.jsdelivr.net/npm/@lljj/vue3-form-naive/dist/vue3-form-naive.umd.min.js)
45+
* umd script 标签形式引入暴露全局变量 `window.vue3FormNaive``window.vue3FormNaive.default` 暴露组件
46+
* [playground](https://form.lljj.me/v3/#/demo?type=Simple&ui=VueNaiveForm)
4147

4248
### @lljj/vue3-form-ant
4349
* 适配ui库:`Vue3` `antdv`
@@ -46,29 +52,31 @@
4652
* umd script 标签形式引入暴露全局变量 `window.vue3FormAnt``window.vue3FormAnt.default` 暴露组件
4753
* [playground](https://form.lljj.me/v3/#/demo?type=Simple&ui=VueAntForm)
4854

49-
#### vue3 ant v-model 特殊处理
55+
#### vue3 ant、naiveUi v-model 特殊处理
5056
例如 `a-input` 组件,ant vue3需要使用 `v-model:value`,但在整个框架内部 `v-model` 都是使用 `modelValue`,所以这里就需要对不一致的props通过中间组件组做转换。
5157

52-
你可以自行转换也可以使用内置方法 `modelValueComponent` 转换,如下:
58+
你可以自行转换,也可以使用内置方法 `modelValueComponent` 转换,如下:
5359
```js
54-
import { modelValueComponent } from '@lljj/vue3-form-ant';
55-
5660
// 返回一个接受 modelValue 和 update:modelValue v-model的组件
61+
import { modelValueComponent } from '@lljj/vue3-form-ant';
5762
const MyFixInputComponent = modelValueComponent('a-input', {
5863
model: 'value' // 这里要根据ant组件 model的参数传递
5964
});
60-
```
6165

62-
**这样使用起来还是有些麻烦,目前已经对常用的Widget组件做了内置,参见 [ant vue 附加全局Widget组件](/zh/guide/components.html#vue3-ant-特有的全局组件)**
63-
64-
----------------------------
66+
// naive 也是类似操作
67+
import { modelValueComponent } from '@lljj/vue3-form-naive';
68+
const MyFixInputComponent = modelValueComponent('n-input', {
69+
model: 'value' // 这里要根据naive组件 model的参数传递
70+
});
71+
```
6572

66-
::: tip
67-
后续的文档都以 `@lljj/vue-json-schema-form` 为例
73+
:::tip
74+
这样使用起来还是有些麻烦,目前已经对常用的Widget组件做了内置,
75+
参见 [ant、naiveUi vue 附加全局Widget组件](/zh/guide/components.html#vue3-ant、naiveui-特有的全局组件)
6876
:::
6977

70-
7178
## 快速开始
79+
> **后续的文档都以 `@lljj/vue-json-schema-form` 为例**
7280
7381
### npm
7482

packages/docs/docs/zh/guide/components.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* [DatePickerWidget](#datepickerwidget)
1313
* [DateTimePickerWidget](#datetimepickerwidget)
1414
* [UploadWidget](#uploadwidget)
15-
* [vue3 ant 特有的](#vue3-ant-特有的全局组件)
15+
* [vue3 ant、naiveUi 特有的](#vue3-ant、naiveui-特有的全局组件)
1616

1717

1818
:::tip
@@ -150,18 +150,19 @@ export default {
150150
## DateTimePickerWidget
151151
> 内部使用 `DatePicker / DateTimePicker` 组件,支持参数透传
152152
153-
## vue3 ant 特有的全局组件
153+
## vue3 ant、naiveUi 特有的全局组件
154154
> 内部使用 `DatePicker / DateTimePicker` 组件,支持参数透
155155
156-
vue3 ant 由于v-model不使用 `model: modelValue`,所以对常用的组件做了转换,如下:
157-
158-
| 组件名 | 对应ant组件 |
159-
| ----------- | ----------- |
160-
| InputWidget | a-input |
161-
| InputNumberWidget | a-input-number |
162-
| AutoCompleteWidget | a-auto-complete |
163-
| SliderWidget | a-slider |
164-
| SwitchWidget | a-switch |
165-
| RateWidget | a-rate |
156+
vue3 ant和naiveUi 由于 `v-model` 默认不使用 `model: modelValue`,所以对常用的组件做了转换,如下:
166157

158+
| 组件名 | 对应ant组件 | 对应Naive组件 |
159+
| ----------- | ----------- |----------- |
160+
| InputWidget | a-input |n-input |
161+
| TextAreaWidget | a-textarea |n-input |
162+
| InputNumberWidget | a-input-number |n-input-number |
163+
| AutoCompleteWidget | a-auto-complete |n-auto-complete |
164+
| SliderWidget | a-slider |n-slider |
165+
| SwitchWidget | a-switch |a-switch |
166+
| RateWidget | a-rate |a-rate |
167167

168+
快速转换 `modelValue` 可参考:[转换v-model组件 `modelValue` 到其它](/zh/guide/#vue3-ant、naiveui-v-model-特殊处理)

0 commit comments

Comments
 (0)