{"id":16430263,"url":"https://github.com/fyl080801/json-to-render","last_synced_at":"2025-03-16T17:35:20.493Z","repository":{"id":43355002,"uuid":"330155027","full_name":"fyl080801/json-to-render","owner":"fyl080801","description":"功能强大的动态界面渲染组件","archived":false,"fork":false,"pushed_at":"2022-03-06T09:13:14.000Z","size":8204,"stargazers_count":39,"open_issues_count":2,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-01T00:13:51.092Z","etag":null,"topics":["html","json","props","vue3"],"latest_commit_sha":null,"homepage":"https://fyl080801.github.io/json-to-render/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fyl080801.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-16T12:13:32.000Z","updated_at":"2024-09-20T00:05:21.000Z","dependencies_parsed_at":"2022-08-20T00:40:29.090Z","dependency_job_id":null,"html_url":"https://github.com/fyl080801/json-to-render","commit_stats":null,"previous_names":[],"tags_count":183,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fyl080801%2Fjson-to-render","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fyl080801%2Fjson-to-render/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fyl080801%2Fjson-to-render/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fyl080801%2Fjson-to-render/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fyl080801","download_url":"https://codeload.github.com/fyl080801/json-to-render/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243823422,"owners_count":20353674,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["html","json","props","vue3"],"created_at":"2024-10-11T08:26:18.441Z","updated_at":"2025-03-16T17:35:19.753Z","avatar_url":"https://github.com/fyl080801.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Json to Render\n\n[![Build Status](https://travis-ci.com/fyl080801/json-to-render.svg?branch=master)](https://travis-ci.com/fyl080801/json-to-render)\n\n将 json 数据渲染成界面的 vue 组件库，是根据 [vjform 动态表单](https://github.com/fyl080801/vjform)、[jformer 动态表单](https://github.com/fyl080801/jformer) 以及[vjdesign 设计器](https://github.com/fyl080801/vjdesign) 相关项目开发的 vue3 版本\n\n详细参考[说明文档](https://fyl080801.github.io/json-to-render/)\n\n## 特性\n\n- 将 json 数据渲染成界面\n- 支持 vue3\n- 支持任何 html 组件和 vue 项目中引用的组件进行渲染，支持组件任何属性\n- 支持将 json 数据特殊对象转换成数据关联关系实现联动\n- 支持二次开发 json 属性解析方式、数据交互来源与渲染逻辑\n\n## 示例项目\n\n此项目安装依赖\n\n```bash\nnpm install\n```\n\n```bash\nnpm run dev\n```\n\n或\n\n```bash\nyarn install\n\n```\n\n```bash\nyarn run dev\n```\n\n## 快速上手\n\n使用 npm 安装\n\n```bash\nnpm i @json2render/vue-full\n```\n\n实现一个简单示例\n\nmain.js\n\n```javascript\nimport { createApp } from 'vue'\nimport App from './App.vue'\nimport JRender from '@json2render/vue-full'\n\ncreateApp(App).use(JRender).mount('#app')\n```\n\nApp.vue\n\n```vue\n\u003ctemplate\u003e\n  \u003cdiv\u003e\n    \u003cv-jrender v-model=\"model\" :fields=\"fields\" /\u003e\n  \u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript lang=\"ts\"\u003e\nimport { defineComponent } from 'vue'\nexport default defineComponent({\n  setup() {\n    return {\n      model: { text1: 'Hello world!!' },\n      fields: [\n        { component: 'p', text: '$:model.text1' },\n        { component: 'input', value: 'model.text1' },\n      ],\n    }\n  },\n})\n\u003c/script\u003e\n```\n\n## 示例\n\n示例 1: [简单示例](http://jsrun.net/2PaKp)\n\n示例 2: [Element 组件](http://jsrun.net/8PaKp)\n\n## 说明\n\n### 渲染组件\n\n一般的定义形式如下\n\n```html\n\u003cv-jrender\n  v-model=\"model\"\n  :fields=\"fields\"\n  :datasource=\"datasource\"\n  :listeners=\"listeners\"\n  @setup=\"onsetup\"\n/\u003e\n```\n\n- v-model: 数据\n- fields: 组件集合\n- datasource: 自定义数据源集合\n- listeners: 监听集合\n- setup: setup 事件\n\n### 组件定义\n\n组件定义包括 `component` `props` `children` 三个基本属性\n\n- component: 组件类型名，只要 html 标签或是项目中引用的组件都可以作为类型名\n- props: 组件的属性，vue3.0 中组件属性、html 属性、事件的定义可以直接定义到一个对象里\n- children: 组件嵌套的下级组件集合\n\n### 组件属性代理\n\n组件定义会被转换成代理对象，组件属性值如果是符合特定的表达式则在运行时会被转换成真实逻辑\n\n### 渲染钩子\n\n在组件被渲染之前会触发传渲染钩子行为，可在渲染之前改变组件的属性，有两个钩子执行的时机\n\n- prerender: 相当于组件 setup 阶段，如果组件定义不被改变则只会执行一次\n- render: 相当于每次渲染之前都会被执行\n\n### 数据源\n\n数据源就是数据的来源，可在组件属性表达式里使用的数据，默认支持 `model` `scope` `arguments` `refs` 这几种数据来源\n\n- model: 通过 v-model 传递过来的数据\n- scope: 当前组件渲染时候由父级数据传递过来的当前数据成员，相当于 scoped-slot\n- arguments: 如果当前属性表达式是一个函数，则 arguments 就是函数接收的参数数组\n- refs: 如果在组件的 props 里设置 ref 属性，则可以通过 refs 获取组件的实例\n\n除了以上几种数据源外，还支持自定义数据源\n\n### 扩展行为\n\n支持扩展组件属性代理行为、渲染钩子、数据源，实现自定义渲染规则\n\n## 相关链接\n\n[说明文档](https://fyl080801.github.io/json-to-render/) 完善中...\n\n## 关于\n\n- 基于 vue2.0 的 vjdesign 设计器定义的配置是否能在这里使用\n\n因为基于 vue2.0 的组件如果不做特殊适配基本上不能在 vue3.0 使用因此不能兼容，但是如果组件库 vue2.0 的属性和 vue3.0 的属性一致，则可以使用自定义渲染钩子将组件属性转换成适用于 vue3.0 的定义实现兼容\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffyl080801%2Fjson-to-render","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffyl080801%2Fjson-to-render","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffyl080801%2Fjson-to-render/lists"}