Vue <a> tag href attribute splicing


My current url is http://localhost:8080/component, and in this page I have an <a> tag

<a :href="'/detail/' + comp._id"></a>

When comp._id is determined, for example it is 6221add333182348e1d70104.

I want the URL to jump to http://localhost:8080/component/detail/6221add333182348e1d70104 when I click on the link.

But actually it is http://localhost:8080/detail/6221add333182348e1d70104.

How can I achieve this ?

>Solution :

You can add /component/to your link. Like: <a :href="'/component/detail/' + comp._id"></a>

Leave a ReplyCancel reply