Zum Inhalt springen
_CORE
AI & Agentic Systems Core Information Systems Cloud & Platform Engineering Data Platform & Integration Security & Compliance QA, Testing & Observability IoT, Automation & Robotics Mobile & Digital Banking & Finance Insurance Public Administration Defense & Security Healthcare Energy & Utilities Telco & Media Manufacturing Logistics & E-commerce Retail & Loyalty
Referenzen Technologien Blog Know-how Tools
Über uns Zusammenarbeit Karriere
CS EN DE
Lassen Sie uns sprechen

Vue 3 Composition API

23. 10. 2019 1 Min. Lesezeit intermediate

Composition API je doporučený způsob psaní Vue 3 komponent. Lepší TypeScript podpora, reusable logika, jednodušší velké komponenty.

Script setup

{{ count }} ({{ doubled }})

Composables

// composables/useFetch.ts export function useFetch(url: string) { const data = ref(null); const error = ref(null); const loading = ref(true); fetch(url) .then(r => r.json()) .then(v => data.value = v) .catch(e => error.value = e) .finally(() => loading.value = false); return { data, error, loading }; } // Použití v komponentě const { data: users, loading } = useFetch(‘/api/users’);

Klíčový takeaway