Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/varletjs/varlet-schema

Lightweight Schema renderer based on Vue3
https://github.com/varletjs/varlet-schema

schema varlet vue3

Last synced: 1 day ago
JSON representation

Lightweight Schema renderer based on Vue3

Awesome Lists containing this project

README

        

### Intro

Varlet Schema is a Lightweight Schema renderer based on Vue3, developed and maintained by `varletjs` community team.

### Install

```shell
# Install with npm or yarn or pnpm

# npm
npm i @varlet/schema-renderer -S

# yarn
yarn add @varlet/schema-renderer

# pnpm
pnpm add @varlet/schema-renderer
```

### Basic Usage

#### Inject eval in index.html

Schema rendering uses eval. Eval is not allowed to be used in strict mode, but script module is in strict mode.
So we have to do the following.

```html


Varlet Schema Playground



```

#### Basic Usage

```vue

import { Button, Snackbar } from '@varlet/ui'
import { SchemaRenderer, type SchemaPageNode } from '@varlet/schema-renderer'
import { shallowRef } from 'vue'

const components = shallowRef({
Button,
})

const injects = shallowRef({
Snackbar
})

const schema = shallowRef<SchemaPageNode>({
name: 'Page',
code: `\
function setup() {
const count = ref(0)

onMounted(() => {
Snackbar('hello')
})

function handleClick() {
count.value++
}

return { count, handleClick }
}\
`,
children: [
{
name: 'Button',
props: {
onClick: {
type: 'Expression',
value: 'handleClick'
}
},
children: [
{
name: 'Text',
value: {
type: 'Expression',
value: 'count.value'
}
}
]
}
]
})

```

### More Example Info

[See Playground](https://github.com/varletjs/varlet-schema/tree/main/packages/varlet-schema-playground)

### Community

We recommend that `issue` be used for problem feedback, or others:

* Wechat group

* Join the [Discord](https://discord.gg/Dmb8ydBHkw)

### Thanks to contributors



### Thanks to the following sponsors



### Sponsor this project

Sponsor this project to support our better creation. It is recommended to use afdian to subscribe, and your avatar will appear in this project.

#### Afdian

https://afdian.net/a/haoziqaq

#### Wechat / Alipay