23 Star 109 Fork 29

Yourtion / vue-json-ui-editor

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

NPM version build status Test coverage David deps npm download npm license

json-editor

Greenkeeper badge DeepScan grade

Edit JSON in UI form with JSON Schema and Vue.js <json-editor> component.

ScreenShot

Install

npm install vue-json-ui-editor --save

Use

<template>
<json-editor ref="JsonEditor" :schema="schema" v-model="model">
    <button @click="submit">submit</button>
    <button @click="reset">Reset</button>
</json-editor>
</template>

<script>
const SCHEMA = {
  type: 'object',
  title: 'vue-json-editor demo',
  properties: {
    name: {
      type: 'string',
    },
    email: {
      type: 'string',
    },
  },
};
// import vue-json-ui-editor
import JsonEditor from '../../src/JsonEditor.vue';
export default {
  components: { JsonEditor },
  data: () => ({
    // init json schma file ( require('@/schema/newsletter') )
    schema: SCHEMA,
    // data
    model: {
      name: 'Yourtion',
    },
  }),

  methods: {
    submit(_e) {
      alert(JSON.stringify(this.model));
    },
    reset() {
      this.$refs.JsonEditor.reset();
    },
  },
};
</script>

More info on: Example-Subscription Schema: newsletter.json

props

  • schema Object (required) The JSON Schema object. Use the v-if directive to load asynchronous schema.

  • v-model Object (optional) default: [object Object] Use this directive to create two-way data bindings with the component. It automatically picks the correct way to update the element based on the input type.

  • auto-complete String (optional) This property indicates whether the value of the control can be automatically completed by the browser. Possible values are: off and on.

  • no-validate Boolean (optional) This Boolean attribute indicates that the form is not to be validated when submitted.

  • input-wrapping-class String (optional) Define the inputs wrapping class. Leave undefined to disable input wrapping.

data

  • default initial value: [object Object]

  • fields initial value: [object Object]

  • error initial value: null

  • data initial value: [object Object]

events

  • input Fired synchronously when the value of an element is changed.

  • change Fired when a change to the element's value is committed by the user.

  • invalid Fired when a submittable element has been checked and doesn't satisfy its constraints. The validity of submittable elements is checked before submitting their owner form, or after the checkValidity() of the element or its owner form is called.

  • submit Fired when a form is submitted

methods

  • input(name) Get a form input reference

  • form() Get the form reference

  • checkValidity() Checks whether the form has any constraints and whether it satisfies them. If the form fails its constraints, the browser fires a cancelable invalid event at the element, and then returns false.

  • reset() Reset the value of all elements of the parent form.

  • submit(event) Send the content of the form to the server

  • setErrorMessage(message) Set a message error.

  • clearErrorMessage() clear the message error.

MIT License Copyright (c) 2017 郭宇翔 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于Vue的JSON可视化编辑器,通过定义 JSON Schema 直接生成 UI 界面 展开 收起
JavaScript 等 3 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/yourtion/vue-json-ui-editor.git
git@gitee.com:yourtion/vue-json-ui-editor.git
yourtion
vue-json-ui-editor
vue-json-ui-editor
master

搜索帮助