1

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 !!

1
  • 1
    You are missing tag quotes: :to="`${title}/create`" Commented Dec 20, 2021 at 19:45

2 Answers 2

3
<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

Sign up to request clarification or add additional context in comments.

Comments

2

Try this:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.