# j-form-table

> 数据驱动的表单式组件

Latest version **0.0.17** (published 2021-09-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install j-form-table
pnpm add j-form-table
yarn add j-form-table
bun add j-form-table
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.17 |
| Published | 2021-09-08 |
| First published | 2021-06-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 13 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | JackChou https://github.com/jackchoumine/ |
| Maintainers | jack-chou-mine |
| Keywords | table, form-table, table-form, vue form, vue-table |

## Links

- npm: https://www.npmjs.com/package/j-form-table
- Repository: https://github.com/jackchoumine/form-table
- Homepage: https://github.com/jackchoumine/form-table#readme
- Issues: https://github.com/jackchoumine/form-table/issues
- npm.io page: https://npm.io/package/j-form-table

## Dependencies (1)

- [clone](https://npm.io/package/clone.md) ^2.1.2

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 0.0.17 (latest) — 2021-09-08
- 0.0.16 — 2021-06-29
- 0.0.15 — 2021-06-09
- 0.0.12 — 2021-06-09
- 0.0.11 — 2021-06-09

## README

# form-table 表单式表格

表单式表格，使用时只需要传需要展示的标题和数据.

> 基于 element-ui 2.x

[![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE)
<a href="https://996.icu"><img src="https://img.shields.io/badge/link-996.icu-red.svg" alt="996.icu"></a>

## 安装

```bash
npm i j-form-table
```

在 vue 应用的入口文件中使用：

```js
import FormTable from 'form-table'
Vue.use(FormTable)
// 可全局配置 title 的宽度 默认是 120 单位 px
Vue.use(FormTable, { titleWidth: 150 })
```

## 常用 props

|      prop      |            说明             |          类型          | 是否必需 | 默认值 |        其他         |
| :------------: | :-------------------------: | :--------------------: | :------: | :----: | :-----------------: |
|   titleList    |          组件配置           | `[]{title:'',prop:''}` |    是    |        |         ``          |
|      data      |    从该属性中取值来展示     |        `Object`        |    否    |  `{}`  |                     |
|     title      |       整个组件的标题        |        `String`        |    否    |  `''`  |                     |
|   titleWidth   |          标题宽度           |        `Number`        |    否    | `120`  |     单位为`px`      |
| titleNumPreRow | 一行有几个`title`、`prop`对 |        `Number`        |    否    |  `3`   | 只能是`1,2,3,4,5,6` |

## 基本用法

配置 `titleList` 和 `data` 即可展示数据；

```html
<template>
  <div>
    <FormTable title="使用例子" :data="data" :titleList="titleList" />
    <FormTable
      title="使用例子"
      :data="data"
      :titleList="titleList"
      :titleWidth="150"
    />
  </div>
</template>

<script>
  const img =
    'https://tva1.sinaimg.cn/large/008i3skNgy1gu9gco1hdbj605k05kgll02.jpg'
  export default {
    name: 'App',
    data() {
      return {
        data: {
          name: 'LiHei',
          image: img,
          job: 'web dev',
          slary: '3000',
          address: '四川省成都市成华区十里店寺庙',
          education: '本科',
          isGood: 1
        },
        titleList: [
          { title: '姓名', prop: 'name' },
          {
            title: '头像',
            // 自定义 title 属性值
            titleTips: data => {
              return (data.image && '生成图，点击放大') || '暂无头像'
            },
            prop: (h, data) => {
              return (
                <div style={{ width: '50px', height: '200px' }}>
                  <img src={data.image} alt='我的头像：超级无敌美丽' />
                </div>
              )
            }
          },
          {
            title: '职业',
            prop: 'job'
          },
          {
            title: '月薪',
            prop: (h, data) => {
              return <span>{data.slary + '$'}</span>
            },
            enableCopy: true // 开启点击赋值内容
          },
          {
            title: '住址',
            prop: 'address',
            enableCopy: true,
            span: 2
          },
          {
            title: '学历',
            prop: 'education',
            span: 1
          },
          {
            title: '是否统招',
            prop: (h, data) => {
              const map = { 0: '否', 1: '是' }
              return <span>{map[data.isGood]}</span>
            },
            span: 2
          }
        ]
      }
    }
  }
</script>
```

效果

![上述渲染效果](https://tva1.sinaimg.cn/large/008i3skNgy1gu9i87hguhj61da0j70u702.jpg)

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