Skip to content

Commit

Permalink
✨ feat: 文档修改
Browse files Browse the repository at this point in the history
  • Loading branch information
ashuicoder committed Dec 19, 2023
1 parent 74d4562 commit fe10881
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 16 deletions.
10 changes: 5 additions & 5 deletions docs/.vitepress/cache/deps/_metadata.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"hash": "1b54282b",
"browserHash": "555ddccc",
"hash": "02274044",
"browserHash": "6c7f6349",
"optimized": {
"vue": {
"src": "../../../../node_modules/.pnpm/[email protected][email protected]/node_modules/vue/dist/vue.runtime.esm-bundler.js",
"file": "vue.js",
"fileHash": "7ebf57ee",
"fileHash": "ece1bcb5",
"needsInterop": false
},
"vitepress > @vue/devtools-api": {
"src": "../../../../node_modules/.pnpm/@[email protected]/node_modules/@vue/devtools-api/lib/esm/index.js",
"file": "vitepress___@vue_devtools-api.js",
"fileHash": "4237f70d",
"fileHash": "3538dd85",
"needsInterop": false
},
"@theme/index": {
"src": "../../../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]_search-in_dbo57d3nsic27itderipp75bdq/node_modules/vitepress/dist/client/theme-default/index.js",
"file": "@theme_index.js",
"fileHash": "ee915d28",
"fileHash": "63f02da1",
"needsInterop": false
}
},
Expand Down
69 changes: 58 additions & 11 deletions docs/naive-ui-form.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,9 @@ import { NConfigProvider, zhCN, dateZhCN, NMessageProvider } from 'naive-ui'

::: tip 提示

如果您在表单中使用了`type: 'upload'`,则需要安装`naive-ui-upload`
- 如果表单中使用了`type: 'upload'`,则需要安装[naive-ui-upload](/naive-ui-upload),并注册该组件。
- 如果表单中使用了`type: 'editpr'`,则需要安装[naive-ui-editor](/naive-ui-editor),并注册该组件。

```shell
pnpm add naive-ui-upload
```

如果您在表单中使用了`type: 'editpr'`,则需要安装`naive-ui-editor`

```shell
pnpm add naive-ui-editor
```
:::

## 基本使用
Expand All @@ -215,7 +207,7 @@ import NaiveUiForm from 'naive-ui-form'

const app = createApp(App)

app.use(NaiveUiForm, Option)
app.use(NaiveUiForm)
```


Expand Down Expand Up @@ -768,3 +760,58 @@ function handleSubmit(values: Recordable) {
<style scoped></style>
```
有时候需要获取整个表单值去做一些额外的事情,如表单校验。`ModalForm`组件暴露了`getValue`方法:
```vue
<template>
<ModalForm
v-model:show="showModal"
title="新增"
ref="modalRef"
:schemas="schemas"
style="width: 800px"
@submit="handleModalSubmit"
></ModalForm>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import {
type FormSchema,
type ModalFormInstance
} from 'naive-ui-form'
const showModal = ref(true)
const schemas: FormSchema[] = [
{
field: 'name',
type: 'input',
label: '姓名',
required: true,
labelPlacement: 'left',
defaultValue: '张三',
componentProps: {
onUpdateValue(value: string) {
console.log(value)
}
},
style: {
width: '200px'
}
},
]
const modalRef = ref<ModalFormInstance | null>(null)
setTimeout(() => {
console.log(modalRef.value?.getValue())
}, 3000)
</script>
<style scoped></style>
```

0 comments on commit fe10881

Please sign in to comment.