How does the "tag" attribute in router-link work?

Viewed 700

I have these two router-links, one enclosed in a li element, the other applied with a tag="li" property:

<router-link tag="li" :to="{ name: 'work'}">Work</router-link
<li><router-link :to="{ name: 'news'}">News</router-link></li>

which a compiled in the browser like so:

enter image description here

Is the tag property of router-link designed to replace html elements? Will both links be recognized by browsers (SEO etc.) the same way? I'd like to shorten my html with the tag property but don't know if I should.

2 Answers

tag attribute does not exist in Vue Router 4 (which is currently only version of router you can use with Vue 3)

It was meant as an option to replace a with something different. However as li can not have href attribute, enclosing <a> inside <li> is your best option

Related