Solve the problem of query dynamic parameter passing in vue-router

亚连
Release: 2018-05-25 16:21:27
Original
1508 people have browsed it

Below I will share with you an article that solves the problem of query dynamic parameter transmission in vue-router. It has a good reference value and I hope it will be helpful to everyone.

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 what? 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. , all failed. Then I accidentally saw a question and answer

    vue-router dynamic configuration of incoming parameters, and then I saw the following code:

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

    {{el.address}}

  • Copy after login

    I suddenly feel like I have an idea. The solution is as follows:

    Bind the id of li in data id, and then write the bound one 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

    Then the url will change It looks like this: http://localhost:8080/editmovie?id=2016987, and the problem is solved.

    The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

    Related articles:

    Ajax method of sending and receiving binary byte stream data

    Use Ajax technology to achieve partial refresh Product quantity and total price example code

    Perfectly solves the problem of Session failure during ajax access

    ##

    The above is the detailed content of Solve the problem of query dynamic parameter passing 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