M
M
MikUrrey2019-09-29 13:38:39
Vue.js
MikUrrey, 2019-09-29 13:38:39

How to properly execute code inside Vue template?

Greetings!
Here is an example code:

<div v-else-if="column.type == 'badge'" :key="value">
                        <v-chip
                            small
                            :style="{
                                'border': '1px solid',
                                'border-color':join('status', 'id', props.value).edge_color||false,
                                'background': join('status', 'id', props.value).badge_color||'#fff',
                                'color': join('status', 'id', props.value).text_color||false
                            }"
                        >{{join('status', 'id', props.value).title||props.value}}</v-chip>
                    </div>

As you can see, here the join method is repeated several times with the same arguments.
How to immediately define an object by calling the method once, so as not to litter in data, computed, props, etc.?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MikUrrey, 2019-09-29
@MikUrrey

Found only one way: to make your own component.
here in the component, just the transferred object is decomposed into the data necessary for output.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question