Vue动态生成表单组件 能够根据数据配置表单 使用的UI库是iView
在Vue里 通常要用到什么组件或数据 都得提早声明
因此要根据数据来生成表单 只能使用Vue的render函数
要作这一个组件 其实并不难 看一下Vue官方示例 再找个UI组件库 差很少就能写出来
若是对项目有兴趣 能够fork或克隆项目 自行研究
有问题或BUG欢迎提issuescss
npm i vue-form-maker
import iView from 'iview' import VueFormMaker from 'vue-form-maker' import 'iview/dist/styles/iview.css' Vue.use(iView) Vue.use(VueFormMaker)
<template> <div id="app"> <VueFormMaker :options="options"/> // 或者 <vue-form-maker :options="options"/> </div> </template>
使用的是dist目录中的vue-form-maker.js
html
<link rel="stylesheet" type="text/css" href="iview.css">
<div id="app"> <vue-form-maker :options="options"/> </div>
<script src="vue.js"></script> <script src="iview.js"></script> <script src="vue-form-maker.js"></script>