Skip to content

Riunshow/vue-json-form

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

基于jsonform的vue动态表单组件

https://github.com/jsonform/jsonform

how to use

main.js

import Vue from 'vue'
import Vuex from 'vuex'
import VJF, { VJFStore } from 'vue-json-form-create'

Vue.use(VJF)

new Vue({
  router,
  store: new Vuex.Store(VJFStore),
  render: h => h(App)
}).$mount('#app')

demo.vue

<template>
  <vue-json-form v-model='formdata1' ref="form1" :formId='1' :formSchema='schema1' />
</template>

<script>
export default {
  data () {
		formdata1: {
      name: 'zxczxc',
      checkboxField: ['option1']
		},
		schema1: {
			schema: {
				name: {
					title: 'Default Name',
					description: 'Nickname allowed',
					type: 'string'
				},
				checkboxField: {
					type: 'array',
					title: '多选框',
					enum: ['option1', 'option2']
				}
			},
			form: [
				{
					key: 'name',
					type: 'input',
					required: true
				},
				{
					key: 'checkboxField',
					type: 'checkboxes',
					required: true,
					titleMap: {
						option1: '选项1',
						option2: '选项2'
					}
				},
        value: {
          name: '',
          checkboxField: []
        }
			]
		}
	}
}
</script>

show

avatar

todolist

  • 初始化的数据绑定到 v-model

  • 表单校验

  • schema from value 三者做映射关系(单选多选 enum 和 titleMap 做映射)

  • 代码优化

  • 组件实现

    • mand-mobile
      • 输入框
      • 多选框
  • 需在vue.config.js中配置alias

const path = require('path')

module.exports = {
	configureWebpack:{
    resolve: {
			extensions: ['.js', '.vue', '.json',".css"],
			alias: {
				'vue$': path.resolve(__dirname, './node_modules/vue/dist/vue.runtime.esm.js')
			}
    }
	}
}

About

基于jsonform的vue动态表单组件

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published