Using v-if in a template inside a computed property doesn't work

185 Views Asked by At

I have a computed property that has an html template (yes unfortunately I have to use it this way) inside it. I want to have a v-if attribute inside the template but it returns an error which I believe is because the variable is being read as a string. How can I fix that?

This is my computed property:

         myProperty(row){
            return `<div class="cell__customer-contact">
                      <div>${row.customerFirstName +
                        " " +
                        row.customerLastName}</div>
                      <div v-if="${row.customerEmail}"> 
                        <a href="mailto:${row.customerEmail}">
                          ${row.customerEmail}
                        </a>
                      </div>
                    </div>`
         }

The error I get is:

invalid expression: Invalid or unexpected token in

    [email protected]

  Raw expression: v-if="[email protected]"
0

There are 0 best solutions below