Generate specific template in Vue

Viewed 20

Is there any way to generate specific template in beforeCreate hook according a statement? I have three roles in my program and I want to generate a specific template foreach roles.

1 Answers

Maybe you could share some code, but what is used in most situations like this could be something as this example :

in your data set something like this:

role: undefined

and set this role in something like Created or Mounted

In your template you can use several v-if statements

// template 1
.div(v-if='role === "staff"')
  content here

// template 2
.div(v-if='role === "visitor"')
  content here

// template 3
.div(v-if='role === "ceo"')
  content here
Related