SARogersz
SARogersz

Reputation: 121

Vue v-text directive: concatenate text from multiple variables

I am trying to concatenate two string values into a element, with no success thus far. This works fine:

    <v-toolbar-title
      class="hidden-sm-and-down font-weight-light"
      v-text="$route.name"
    />

But I need to concatenate the following to $route.name somehow: ' (' + {{sitename}} + ')' so that the value of local variable sitename follows the route name.

Is this possible to do in the v-text directive, or do I have to jump through hoops to assemble the string elsewhere?

Upvotes: 0

Views: 1035

Answers (1)

hatef
hatef

Reputation: 6199

I believe you could do something like this:

v-text="`${$route.name}(${sitename})`"

If you'd like to read more about string concatenation in ES6 you can have a look at this article.

Upvotes: 2

Related Questions