search

Home  >  Q&A  >  body text

javascript - How to dynamically control the router-link in vue-router not to jump when clicked

RT
Problem description:
There is a link rendered by router-link in the page. Under certain circumstances, this link can jump, but under certain circumstances, it cannot jump.

Thinking:
How can we make router-link non-jumpable?

<router-link v-bind:to="url" >
   //come code                   
</router-link>

Finally adopted hack method:

When you don’t want the user to click to jump, the url is set to the url of the current page. When you want to click to jump, the url is set to the target url

PHP中文网PHP中文网2735 days ago901

reply all(3)I'll reply

  • 習慣沉默

    習慣沉默2017-05-19 10:28:01

    Use programmatic navigation

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-19 10:28:01

    Then don’t you have to judge the situation? Let’s write a function using the a tag to judge

    reply
    0
  • ringa_lee

    ringa_lee2017-05-19 10:28:01

    Use programmatic navigation. Specifically, use other tags such as li to bind click events (if you need to disable it, remember to add the disabled status to be complete). After business logic judgment in the event callback function, decide whether to use this.$route.push(url string Or url object entity) method to jump.

    reply
    0
  • Cancelreply