ElementAttributes
tipo Since 1.5.0
Atributos que acepta bind="obj" en un elemento Tag: los globales (class, id, role,
aria-*, data-*…) y los propios de la etiqueta según los datos HTML de Meeko. Con una unión de
etiquetas vale cualquier atributo de alguna de ellas; un valor null, undefined o false no
escribe el atributo. No admite claves on*: los manejadores no se crean desde datos. Desde 1.8,
el tipo de cada valor ofrece al completado los valores del estándar ("submit" | "reset" | "button" en type de <button>) sin dejar de admitir cualquier otro (véase AttributeValueOf).
import type { ElementAttributes } from "@meekojs/meeko";Source code src/app/runtime/dynamic-tag.ts:71
Declaración #
type ElementAttributes<Tag extends string = TagName> = { readonly [Name in AttributeNameOf<Tag>]?: AttributeValueOf<Tag, Name> }Type parameters #
-
Tagextends string = TagName Etiqueta o unión de etiquetas del elemento.
Example #
<script lang="ts">
import { computed } from "@meekojs/meeko";
import type { ElementAttributes } from "@meekojs/meeko";
const props = defineProps<{ href?: string; busy: boolean }>();
const state = computed((): ElementAttributes<"a" | "button"> => ({ "aria-busy": props.busy, "data-kind": props.href ? "link" : "action" }));
</script>
<template><component is="props.href ? 'a' : 'button'" bind="state.value" bind:href="props.href">Abrir</component></template>See also #
- Bulk attributes with bind Componentes y API