GithubHelp home page GithubHelp logo

Comments (5)

posva avatar posva commented on June 25, 2024

And what does this option do?

from router.

AlttiRi avatar AlttiRi commented on June 25, 2024

Adds the class ("router-target-element" from the example above) to the element with the id the same as the URL's hash.
So, it can be used as an alternative to :target CSS selector which does not work with vue-router.

:target, .router-target-element {
  font-weight: bold;
}

For example, the route /main#1 will add the router-target-element class to the element with id 1.

from router.

posva avatar posva commented on June 25, 2024

I see, so it's specific to the web hash history and what you mentioned on #2230. It can be solved by creating that custom history you proposed, which seems more appropriate than introducing a new option that only applies to a specific history mode.

from router.

AlttiRi avatar AlttiRi commented on June 25, 2024

it's specific to the web hash history

No, this applicable to both createWebHistory and createWebHashHistory.
With createWebHistory mode the :target CSS selector does not work too.

> Setting the hash with History API do not affect on styling the element with :target selector.


I'm not the only one who faced this issue:

So, it can be simple fixed with the similar option as linkActiveClass and linkExactActiveClass.

from router.

posva avatar posva commented on June 25, 2024

Thanks for pointing out #2076 , I forgot about it being a spec limitation. You should follow w3c/csswg-drafts#6942 for a proper implementation of this.

You can implement the feature in many ways. The most reusable one would be a custom Router Link by checking the current route and the this custom link resolved route's hash

from router.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.