vform-next
v3.1.3
Published
1. 安装 ``` npm i vform-next ``` 2. 引入表单设计器组件 ```javascript import { createApp } from 'vue' import App from './App.vue' import axios from 'axios' //如果需要axios,请引入
Readme
vform-next
Vue 2.x/3.x 表单设计器。基于 variant-form3-vite 修改
使用说明
- 安装
npm i vform-next- 引入表单设计器组件
import { createApp } from 'vue'
import App from './App.vue'
import axios from 'axios' //如果需要axios,请引入
import ElementPlus from 'element-plus' //引入element-plus库
import VForm3 from 'vform-next/dist/lib/designer.umd.js'; //引入VForm3库
import 'element-plus/dist/index.css' //引入element-plus样式
import 'vform-next/dist/lib/designer.style.css' //引入VForm3样式
const app = createApp(App)
app.use(ElementPlus) //全局注册element-plus
app.use(VForm3) //全局注册VForm3(同时注册了v-form-designe、v-form-render等组件)
/* 注意:如果你的项目中有使用axios,请用下面一行代码将全局axios复位为你的axios!! */
window.axios = axios
app.mount('#app')- 使用 designer 组件
<template>
<div class="layout-padding">
<v-form-designer ref="designerRef">
<template #customToolButtons>
<el-button type="primary" size="default" @click="openSaveFormDialog">{{ $t('message.button.save') }}</el-button>
</template>
</v-form-designer>
</div>
</template>- 使用 render 组件
<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 setup>
import { ref, reactive } from 'vue'
import { ElMessage } from 'element-plus'
/* 注意:formJson是指表单设计器导出的json,此处演示的formJson只是一个空白表单json!! */
const formJson = reactive({"widgetList":[],"formConfig":{"modelName":"formData","refName":"vForm","rulesName":"rules","labelWidth":80,"labelPosition":"left","size":"","labelAlign":"label-left-align","cssCode":"","customClass":"","functions":"","layoutType":"PC","jsonVersion":3,"onFormCreated":"","onFormMounted":"","onFormDataChange":"","onFormValidate":""}})
const formData = reactive({})
const optionData = reactive({})
const vFormRef = ref(null)
const submitForm = () => {
vFormRef.value.getFormData().then(formData => {
// Form Validation OK
alert( JSON.stringify(formData) )
}).catch(error => {
// Form Validation failed
ElMessage.error(error)
})
}
</script>What's new
- 2025-07-31: v3.1.2
- 增加表单属性 formTemplates,以支持从外部设置表单 JSON
- 修改模板JSON和封面图由远程获取改为本地引入
- 升级 element-ui 到 2.7.9 并修复 warning:
passive event listener to a scroll-blocking 'touchstart' event. - 修复
ClipboardJS undefined错误 - 修复 aria-hide warning:
Blocked aria-hidden on an element because its descendant retained focus.
- 2025-07-30: v3.1.1
- 修复并升级为 Vite 5.4, Vue 3.5, element-plus 2.8,解决 Vue 3.5 下多个组件属性兼容性报错问题
- 删除了 旧版 vuedraggable 及相关引用,修复并升级为 vue3-draggable-next,以解决在 Vue3.5 下的报错问题
