1.0.60 • Published 1 year ago

otd-avue v1.0.60

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

简介

Vue3.0 版本,因 Avue 还存在一些 bug,请慎重使用。

本项目是一款基于 Avue 的表单设计器,拖拽式操作让你快速构建一个表单。

创建项目

使用 Vue 脚手架 vue-cli 创建基础项目。

安装依赖

yarn add element-plus @smallwei/avue@next otd-avue@next

如果要使用富文本字段,需单独安装依赖

yarn add avue-plugin-ueditor

引入依赖

main.js

import Vue from "vue";
import App from "./App.vue";

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
Vue.use(ElementPlus);

import Avue from "@smallwei/avue";
import "@smallwei/avue/lib/index.css";
Vue.use(Avue);

import OtdAvue from "otd-avue";
Vue.use(OtdAvue);

// 如果要使用富文本字段
import AvueUeditor from "avue-plugin-ueditor";
Vue.use(AvueUeditor);

Vue.config.productionTip = false;

new Vue({
  render: (h) => h(App),
}).$mount("#app");

页面展示

App.vue

<template>
  <div id="app">
    <otd-avue style="height: 100vh;"></otd-avue>
  </div>
</template>

至此,一个最简单的示例就完成了。

基本属性

asideLeftWidth | 左侧操作栏宽度 | String/Number

默认'270px'

<template>
  <otd-avue style="height: 100vh;" aside-left-width="270px"></otd-avue>
</template>

asideRightWidth | 右侧操作栏宽度 | String/Number

默认'380px'

<template>
  <otd-avue style="height: 100vh;" aside-right-width="380px"></otd-avue>
</template>

storage | 本地缓存 | Boolean

是否开启本地缓存,默认false。开启后可防止刷新页面导致操作丢失。

<template>
  <otd-avue style="height: 100vh;" storage></otd-avue>
</template>

undoRedo | 撤销/重做 | Boolean

是否开启撤销/重做功能。默认true

<template>
  <otd-avue style="height: 100vh;" undo-redo></otd-avue>
</template>

options | 配置 | Object/String

Avue 中 avue-form 的 option 配置。用于控制设计区域的初始展示。更多妙用可以看其他 demo。

  • 注意,配置了 storage 之后,会优先从本地缓存中读取数据,options 可能会失效。
<template>
  <otd-avue style="height: 100vh;" :options="options"></otd-avue>
</template>

<script>
  export default {
    data() {
      return {
        options: {
          // 可以是Object
          column: [
            {
              label: "单行文本",
              prop: "input",
              type: "input",
            },
          ],
        },
        // options: `{ column: [{ label: '单行文本', prop: 'input', type: 'input' }] }`, // 也可以是String,用于接口请求后直接赋值
      };
    },
  };
</script>

showGithubStar | github 星星链接 | Boolean

默认true。开源不易,且用且珍惜。:laughing:

toolbar | 顶部操作栏 | Array

如何自定义顶部操作栏

includeFields | 左侧字段显示 | Array

如何自定义左侧字段显示

customFields | 自定义组件 | Array

如何在左侧使用自定义组件

文档及 demo 项目

Wiki

依赖

element-plus

$ npm i element-plus

@smallwei/avue 3.0.0+

$ npm i @smallwei/avue@next

或自行引入 cdn

安装

组件

$ npm i otd-avue@next
或
$ yarn add otd-avue@next
$ yarn
$ yarn serve

html

详见 examples

使用

import OtdAvue from 'otd-avue'

Vue.use(OtdAvue)
<otd-avue style="height: 86vh;"
                  :options="options"
                  storage
                  @submit="handleSubmit"></otd-avue>

属性

参数说明类型默认值
options字段配置Object/String{ column: [] }
storage开启本地存储功能,防止浏览器刷新丢失 jsonBooleanfalse
asideLeftWidth左工具栏宽度String/Number'270px'
asideRightWidth右工具栏宽度String/Number'380px'
showAvueDoc(已废弃,请使用 toolbar)是否显示 Avue 文档Booleanfalse
showGithubStar是否显示 GitHub StarBooleantrue
toolbar顶部工具栏Array'avue-doc', 'import', 'generate', 'preview', 'clear'
undoRedo是否开启撤销重做功能Booleantrue
includeFields左侧展示字段ArrayfieldsConfig.js 中配置的字段
customFields自定义组件Array使用方法

options 字段配置

Avue 文档

属性说明类型可选值默认值
columnAvue 字段Array-[]
labelPosition字段位置String'left'/'center'/'right'-
labelWidth字段宽度Number--
gutter字段间隔Number-0
menuBtn表单按钮Booleantrue/falsetrue
submitBtn显示提交按钮Booleantrue/falsetrue
submitText提交按钮文本String-'提交'
emptyBtn显示清空按钮Booleantrue/falsetrue
emptyText清空按钮文本String-'清空'
tabs多分组转标签Booleantrue/falsefalse
detail详情模式Booleantrue/falsefalse
readonly全局只读Booleantrue/falsefalse
disabled全局禁用Booleantrue/falsefalse

事件

名称说明回调参数
submit生成 json 回调当前配置的 json

方法

名称说明参数返回
getData获取当前编辑器的 JSONtype: 'string'/'json'Promise

插槽

名称说明
toolbar顶部工具栏右侧插槽
toolbar-left顶部工具栏左侧插槽

Avue 插件

富文本

import AvueUeditor from 'avue-plugin-ueditor'

Vue.use(AvueUeditor)

打包

组件

$ yarn lib

源码

$ yarn build

License

MIT

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.60

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

1.0.37

1 year ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

1.0.39

1 year ago

1.0.38

1 year ago

1.0.40

1 year ago

1.0.44

1 year ago

1.0.43

1 year ago

1.0.42

1 year ago

1.0.41

1 year ago

1.0.48

1 year ago

1.0.47

1 year ago

1.0.46

1 year ago

1.0.45

1 year ago

1.0.49

1 year ago

1.0.51

1 year ago

1.0.50

1 year ago

1.0.55

1 year ago

1.0.53

1 year ago

1.0.52

1 year ago

1.0.59

1 year ago

1.0.15

1 year ago

1.0.58

1 year ago

1.0.14

1 year ago

1.0.57

1 year ago

1.0.13

1 year ago

1.0.56

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

3.0.0-beta.9

1 year ago

3.0.0-beta.8

1 year ago

3.0.0-beta.7

1 year ago

3.0.0-beta.6

1 year ago

3.0.0-beta.5

1 year ago

3.0.0-beta.4

1 year ago

3.0.0-beta.3

1 year ago

3.0.0-beta.2

1 year ago

3.0.0-beta.1

1 year ago