href tag breaks vue template component


I am trying to add a href link with a variable in my vue template, for some reason it keeps breaking and I have no clue why, it’s trying to reference it as a variable rather than a link. the issue is with the "/post/update" href. the "/view-user/ +" works fine

<div id="content">
    <div class="post">
        <a :href="/view-user/ +">
        <p>{{ post.created_at.split(".")[0] }}</p>
        <a :href="/post/update/ +">Edit</a>
    <comment :id="id"/>

>Solution :

The static part of the href value should be wrapped by '' as string :

 <a :href="'/view-user/' +">

or string template :

 <a :href="`/view-user/${}`">

in your case it’s evaluated as expression.

Leave a Reply Cancel reply