Variant Form
📄

Variant Form

Type
网站
Description
Vue的可视化低代码表单
Tags
生产力工具
开发类
设计类
notion image
🚀一款高效的Vue 2低代码表单,可视化设计,一键生成源码,享受更多摸鱼时间

⚡️ 跟Vue 2项目集成

1. 安装

2. 引入并全局注册VForm组件

import Vue from 'vue' import App from './App.vue' import axios from 'axios' //如果需要axios,请引入 import ElementUI from 'element-ui' //引入element-ui库 import VForm from 'vform-builds' //引入VForm库 import 'element-ui/lib/theme-chalk/index.css' //引入element-ui样式 import 'vform-builds/dist/VFormDesigner.css' //引入VForm样式 Vue.config.productionTip = false Vue.use(ElementUI) //全局注册element-ui Vue.use(VForm) //全局注册VForm(同时注册了v-form-designer和v-form-render组件) /* 注意:如果你的项目中有使用axios,请用下面一行代码将全局axios复位为你的axios!! */ window.axios = axios new Vue({ render: h => h(App), }).$mount('#app')

3. 在Vue 2模板中使用表单设计器组件

<template> <v-form-designer></v-form-designer> </template> <script> export default { data() { return { } } } </script> <style lang="scss"> body { margin: 0; /* 如果页面出现垂直滚动条,则加入此行CSS以消除之 */ } </style>

4. 在Vue 2模板中使用表单渲染器组件

<template> <div> <v-form-render :form-json="formJson" :form-data="formData" :option-data="optionData" ref="vFormRef"> </v-form-render> <el-button type="primary" @click="submitForm">Submit</el-button> </div> </template> <script> export default { data() { return { /* 注意:formJson是指表单设计器导出的json,此处演示的formJson只是一个空白表单json!! */ formJson: {"widgetList":[],"formConfig":{"labelWidth":80,"labelPosition":"left","size":"", "labelAlign":"label-left-align","cssCode":"","customClass":"","functions":"","layoutType":"PC", "onFormCreated":"","onFormMounted":"","onFormDataChange":""}}, formData: {}, optionData: {} } }, methods: { submitForm() { this.$refs.vFormRef.getFormData().then(formData => { // Form Validation OK alert( JSON.stringify(formData) ) }).catch(error => { // Form Validation failed this.$message.error(error) }) } } } </script>