Home > Enterprise >  Vuejs : rendering dynamic link in a button base on probs
Vuejs : rendering dynamic link in a button base on probs

Time:12-21

I have a create button above my table, I'm trying to render dynamic :to v-bind

Since I have access to {{title}}

Ex. {{title}} = apple, orange, any string

I've tried

<router-link :to=`${title}/create`>
    <v-btn color="blue white--text mt-5 mr-8">
        <span>Create</span>
    </v-btn>
</router-link>

I get

enter image description here


Try #2

to="{title}/create"

link redirect wrong!

http://localhost:8080/{title}/create


Try #3

to="{{title}}/create"

crashed !!

CodePudding user response:

<router-link :to="`${title}/create`">
    <v-btn color="blue white--text mt-5 mr-8">
        <span>Create</span>
    </v-btn>
</router-link>

vue-directives are ALWAYS wrapped with double-quotes, even if you are using template literal

CodePudding user response:

Try this:

<router-link :to="`${title}/create`">
  • Related