_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
References Technologies Blog Know-how Tools
About Collaboration Careers
CS EN
Let's talk

Vue 3 Composition API

23. 10. 2019 1 min read 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’);

Key Takeaway