V
V
Vyacheslav2017-10-11 09:24:19
Vue.js
Vyacheslav, 2017-10-11 09:24:19

How to v-if inside one tag in template vue?

Hey! :)
there is such a template:

<template>
...
  <a :href="`/${param._id}`" v-if="!param.new" style="opacity:.5">
  <a :href="`/${param._id}`" v-if="param.new">
...
</template>

I need to add a style property if the param.new value is missing.
Judging by the documentation, v-if can only be set in a similar way,
but is there any more traditional one, within 1 tag?
something like
{{if param.new}}style=""{{/if}}
don't want to somehow duplicate tags like this

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2017-10-11
@Prow1er

Assign classes, not styles: Well, or in style, enter properties from data.

A
Anton Anton, 2017-10-11
@Fragster

Vue has very good documentation in Russian https://ru.vuejs.org/v2/guide/class-and-style.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question