Atousa Darabi
Atousa Darabi

Reputation: 927

How add class to "template" tag in vue?

I need to know how can I add a class to "template" tag in vue.

<template 
  #popover
  class: templateClass // Is it possible to add a class in here?
>
  <router-link
    v-close-popover
    to="/somewhere"
  >
    Go to the page
  </router-link>
</template>

Upvotes: 5

Views: 12679

Answers (1)

Braks
Braks

Reputation: 639

You can't bind any classes to the template tag as the template tag itself does not render an element for itself. What you're trying to achieve is not possible despite the comments made on the contrary. There's a reason why Vue2 needs a root element for it's components. Adding #templateRef to the template-tag is just a shorthand for v-slot (see What do the hash marks (#) mean in Vue?) and does basically nothing for you in this case.

Upvotes: 7

Related Questions