# element-plus-schema-form

> A Vue3 component for building Web forms from JSON Schema.

Latest version **0.0.4** (published 2021-05-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install element-plus-schema-form
pnpm add element-plus-schema-form
yarn add element-plus-schema-form
bun add element-plus-schema-form
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2021-05-08 |
| First published | 2021-04-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 1.1 MB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 20 |
| Author | label-fe |
| Maintainers | vcreact |
| Keywords | vue3, vite, element-plus, scheme-form |

## Links

- npm: https://www.npmjs.com/package/element-plus-schema-form
- Repository: https://github.com/WsmDyj/element-plus-schema-form
- Homepage: https://github.com/WsmDyj/element-plus-schema-form#readme
- Issues: https://github.com/WsmDyj/element-plus-schema-form/issues
- npm.io page: https://npm.io/package/element-plus-schema-form

## Dependencies (2)

- [vue](https://npm.io/package/vue.md) ^3.0.5
- [element-plus](https://npm.io/package/element-plus.md) ^1.0.2-beta.37

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.4 (latest) — 2021-05-08
- 0.0.3 — 2021-04-28
- 0.0.2 — 2021-04-28
- 0.0.14 — 2021-04-28

## README

# element-plus-schema-form

[![npm][npm-img]][npm-url] [![node][node-img]][node-url]

一个简单的 Vue3 组件，能够使用 JSON 模式以声明方式构建和定制 web 表单。基于 Vue3、Vite、Element-plus 构建

## 安装

**node version:** >=12.0.0

**vite version:** >=2.0.0

```
npm i element-plus-schema-form
```

## 基本使用

```ts
<template>
  <SchemaForm :schemas="schemas" />
</template>
<script>
import { defineComponent } from 'vue'
import { SchemaForm } from 'element-plus-schema-form'

const schemas = [
  {
    field: 'field1',
    component: 'Input',
    label: '字段1',
  }
]
export default defineComponent({
  components: { SchemaForm },
  setup () {
    return {
      schemas
    }
  }
})
</script>
```

## useForm 方式

- `需要使用 register 注册组件才能拿到内部的方法`
- `或者直接通过组件的 ref 也可拿到内部的方法`

```ts
<template>
  <SchemaForm @register=register />
</template>
<script>
import { defineComponent } from 'vue'
import { SchemaForm, useForm } from 'element-plus-schema-form'

const schemas = [
  {
    field: 'field1',
    component: 'Input',
    label: '字段1',
  }
]
export default defineComponent({
  components: { SchemaForm },
  setup () {
    const { register } = useForm(schemas)
    return {
      schemas
    }
  }
})
</script>
```

## 组件示例

> packages/schema-form

**运行示例**

```bash

npm install

npm run dev

```

## 示例项目

[可视化示例](https://wsmdyj.github.io/element-plus-schema-form)

[代码运用示例](https://github.com/WsmDyj/element-plus-schema-form/blob/main/examples/views/home/components/schema-form.vue)

## License

MIT

[npm-img]: https://img.shields.io/npm/v/vite-plugin-style-import.svg
[npm-url]: https://npmjs.com/package/vite-plugin-style-import
[node-img]: https://img.shields.io/node/v/vite-plugin-style-import.svg
[node-url]: https://nodejs.org/en/about/releases/

---
_Source: https://npm.io/package/element-plus-schema-form · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
