# 🏷️ 在线示例
👉 基础表单功能
一个简单的人员信息登记表
👉 组件交互演示
通过事件和API方法切换组件
👉 子表单演示(限Pro版)
子表单小计和累计自动更新
👉 组件联动演示
通过事件和API方法实现联动控制
🚀 这里有更多...
点击查看更多表单模板示例
- name: 👉 基础表单功能
desc: 一个简单的人员信息登记表
link: http://120.92.142.115/?case=vcase1
bgColor: '#DFEEE7'
textColor: '#2A3344'
- name: 👉 组件交互演示
desc: 通过事件和API方法切换组件
link: http://120.92.142.115/?case=vcase2
bgColor: '#DFEEE7'
textColor: '#2A3344'
- name: 👉 子表单演示(限Pro版)
desc: 子表单小计和累计自动更新
link: http://120.92.142.115/pro/?case=vcase3
bgColor: '#DFEEE7'
textColor: '#2A3344'
- name: 👉 组件联动演示
desc: 通过事件和API方法实现联动控制
link: http://120.92.142.115/?case=vcase4
bgColor: '#DFEEE7'
textColor: '#2A3344'
- name: 🚀 这里有更多...
desc: 点击查看更多表单模板示例
link: /pages/form-templates/
bgColor: '#DFEEE7'
textColor: '#2A3344'
# ⚡️ 跟Vue 2项目集成
# 1. 安装
npm i vform-builds
yarn add vform-builds
// Make sure to add code blocks to your code group
# 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')
// Make sure to add code blocks to your code group
# 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>
// Make sure to add code blocks to your code group
# 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>
// Make sure to add code blocks to your code group
# 🔔 技术交流群
# 🎉 最近更新
# 许可协议
# 🎖 特别鸣谢
