How to handle the dynamic parameter passing of query in vue-router

php中世界最好的语言
Release: 2018-06-15 10:49:13
Original
1690 people have browsed it

This time I will show you how to handle the dynamic parameter transfer of query in vue-router, and what are the precautions for dynamic parameter transfer of query in vue-router. The following is a practical case, let's take a look.

I have been writing a project recently. In the process of writing the project, I always find problems of one kind or another. For example, how does the query in vue-router pass dynamic parameters? After some twists and turns, the problem was solved.The problem is described as follows:

I hope the url will be like this when jumping: http://localhost:8080/editmovie?id=****

  • 修改
  • Copy after login

    but? The above is just a static one, the url will always be: http://localhost:8080/editmovie?id=111

    In fact, the id I need is placed in a hidden element In:

  • 2016987
  • Copy after login

    At first my idea was to call the methods in the components, but I tried several times and failed. Then I accidentally saw a question and answer

    vue-router dynamically configures the incoming parameters problem, and then I saw the following code:

  • {{el.tourism_name}} {{el.tog_line_id}}

    {{el.address}}

  • Copy after login

    I suddenly felt like I had an idea. The solution is as follows:

    Bind the id of li to the id in the data, and then write the bound id in the query.

  • 修改
  • Copy after login
    export default { name : 'Movie', data() { return { id : "" } }, methods: { getId () { var id = $('.hiden').eq(0).text(); console.log(id); } }, mounted() { this.id = $('.hiden').eq(0).text(); }, components : { Heade, Foot } }
    Copy after login

    I believe I read it You have mastered the method in the case of this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

    Recommended reading:

    mint-ui makes pull-down refresh and pull-up loading on the mobile phone

    JS dynamic addition Method comparison with PHP dynamic addition method

    The above is the detailed content of How to handle the dynamic parameter passing of query in vue-router. For more information, please follow other related articles on the PHP Chinese website!

    Related labels:
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn