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

https://github.com/kejunmao/vite-plugin-slots-layouts

Slots-based layout for Vue 3 applications using Vite
https://github.com/kejunmao/vite-plugin-slots-layouts

layouts uniapp uniapp-layouts vite-plugin vue-layout

Last synced: 4 months ago
JSON representation

Slots-based layout for Vue 3 applications using Vite

Awesome Lists containing this project

README

          


logo of vite-plugin-slots-layouts repository

vite-plugin-slots-layouts

Slots-based layout for Vue 3 applications using Vite. WIP

English | [简体中文](./README.zhCN.md)

## Installation

```bash
pnpm i -D vite-plugin-slots-layouts
```

## Usage

```ts
// vite.config.ts
import { defineConfig } from "vite";
import Layout from "vite-plugin-slots-layouts";

export default defineConfig({
plugins: [Layout()],
});
```

In main.ts, import the generated code and call `app.use()`

```ts
// main.ts
import App from "./App.vue";
import layouts from "virtual:slots-layouts";
const app = createApp(App);

app.use(layouts);
```

## Client Types

```ts
///
```

## Configuration

see [types.ts](./src/types.ts)

## Layout Block

Use layout-block to set the layout configuration of the page

```vue

{
":isPost": false,
"v-bind": "obj",
"@change": "handleLayoutChange"
}

```

### props

- `name`: set layout
- `disabled`: disabled layout

### content

The content is JSON string, you can use the template syntax supported by Vue.

```vue

```

## How it works

Registration layout dirs components

- blog/index.vue
- component: ``
- layout: `blog`
- blog/header-and-footer.vue
- component: ``
- layout: `blogHeaderAndFooter`

Read pages layout-block

```html

```

Replace page template with wapper layout component

Before:

```html


default footer

```

```html

page
footer

...

```

After:

```html


page
footer

...

```

That means you have the full flexibility of the slots API at your disposal.