Skip to content
Advertisement

Vuejs : rendering dynamic link in a button base on probs

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/%7Btitle%7D/create


Try #3

to=”{{title}}/create”

crashed !!

Advertisement

Answer

<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

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement