Skip to content
Meeko
Type to search the guides and the API reference. Open it from any page with / or Ctrl K; move with the arrow keys and open a result with Enter.
Get started

Contents

On this page

Not translated yet

This page has not been translated into English yet, so it is shown in Spanish.

Snippet

interfaz Since 1.1.0

Contenido de plantilla que un padre pasa a un hijo y que el hijo coloca con <render>. Args son los parámetros que el hijo le entrega. Es el tipo de cada campo que devuelve defineSnippets<T>(); sólo sirve para tipar, su contenido en tiempo de ejecución es interno. Desde 1.4, una clave de T también puede ser un Snippet<Args>, que cuenta como Args: así defineSnippets<Omit<AppCardSnippets, "footer">>() reutiliza los snippets de otro componente.

ts
import type { Snippet } from "@meekojs/meeko";

Source code src/app/runtime/snippets.ts:35

Declaración #

ts
interface Snippet<Args extends readonly unknown[] = []> {
	readonly [snippetArguments]?: (...args: Args) => void
}

Type parameters #

Args extends readonly unknown[] = []

Tupla de parámetros que recibe el snippet.

Example #

meeko
<script lang="ts">
const props = defineProps<{ names: string[] }>();
// snippets.item es Snippet<[name: string]>.
const snippets = defineSnippets<{ item: [name: string] }>();
</script>
<template><ul><li each:of="props.names" each:as="name"><render snippet="snippets.item" args="name" /></li></ul></template>

Was this page helpful?

Add a comment

It is sent when you choose “Yes” or “No”. Only the page, your answer and the comment are stored: no cookies and no personal data.

0 of 2000 characters

Edit on GitHub: packages/meeko/src/app/runtime/snippets.ts