Vue templates: avoid functions, use computed properties instead

preview_player
Показать описание
Instead of calling functions directly in your vue templates, use computed properties. Why? you might ask.

The answer is simple: functions called within vue templates will execute every time the component re-renders. If those functions are computationally expensive, they can decrease the performance of your application. And you don't want that, do you? 😁

Рекомендации по теме
Комментарии
Автор

you can pass parameters to computed properties too:

<script setup>
const fullName = computed(() => (person) => `${person.firstName} ${person.lastName}`);

</script>
<template>
<div>
<p v-for="person in people" :key="person.id">
{{ fullName(person) }}
</p>
</div>
</template>

kristiyan.zhelyazkov
Автор

Hey Constantin,

Great content as always your channel is very underrated

One question: which theme & font are you using for your IDE?

Thanks

crivion