search
HomeWeb Front-endJS TutorialHow to implement dynamic parameter passing of query in vue-router

This time I will show you how to implement the dynamic parameter transfer of query in vue-router, and what are the things to note . 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=****


  • 修改
  • but? The above is just a

    static, the url will always be: http://localhost:8080/editmovie?id=111

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

    
    
  • 2016987
  • At first, my idea was to call the methods in the components, but I tried several times and failed. I accidentally saw a Q&A

    vue-routerDynamic ConfigurationIncoming parameter problem, and then I saw the following code:

    
    
  •     How to implement dynamic parameter passing of query in vue-router   

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

      

    {{el.address}}

     
  • I suddenly feel like I have 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. That’s it

    
    
  • 修改
  • 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
     }
    }
    I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

    Recommended reading:

    Use JS to detect computer configuration (with code)

    How to customize the opening and closing of the vue project eslint verification

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

    Statement
    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
    Vue应用中遇到vue-router的错误“NavigationDuplicated: Avoided redundant navigation to current location” – 怎么解决?Vue应用中遇到vue-router的错误“NavigationDuplicated: Avoided redundant navigation to current location” – 怎么解决?Jun 24, 2023 pm 02:20 PM

    Vue应用中遇到vue-router的错误“NavigationDuplicated:Avoidedredundantnavigationtocurrentlocation”–怎么解决?Vue.js作为快速而灵活的JavaScript框架在前端应用开发中越来越受欢迎。VueRouter是Vue.js的一个代码库,用于进行路由管理。然而,有时

    一文深入详解Vue路由:vue-router一文深入详解Vue路由:vue-routerSep 01, 2022 pm 07:43 PM

    本篇文章带大家详解Vue全家桶中的Vue-Router,了解一下路由的相关知识,希望对大家有所帮助!

    如何通过拖放在Power Query中对多列进行重新排序如何通过拖放在Power Query中对多列进行重新排序Mar 14, 2024 am 10:55 AM

    在这篇文章中,我们将向你展示如何通过拖放在PowerQuery中对多列进行重新排序。通常,从各种来源导入数据时,列可能不是所需的顺序。重新排序列不仅允许您按照符合您的分析或报告需求的逻辑顺序排列它们,还可以提高数据的可读性,并加快过滤、排序和执行计算等任务。如何在Excel中重新排列多个列?在Excel中,重新排列列的方法有多种。您可以简单地选择列标题,然后将其拖动到所需位置。但是,当处理包含许多列的大表时,这种方法可能会变得繁琐。为了更高效地重新排列列,您可以使用增强查询编辑器。通过增强查询编

    React Query 数据库插件:实现数据导入和导出的方法React Query 数据库插件:实现数据导入和导出的方法Sep 26, 2023 pm 05:37 PM

    ReactQuery数据库插件:实现数据导入和导出的方法,需要具体代码示例随着ReactQuery在前端开发中的广泛应用,越来越多的开发者开始使用它来管理数据。而在实际开发中,我们经常需要将数据导出到本地文件或从本地文件导入数据到数据库中。为了更方便地实现这些功能,可以使用ReactQuery数据库插件。ReactQuery数据库插件提供了一系列方

    在Vue应用中使用vue-router时出现“Error: Failed to resolve async component: xxx”怎么解决?在Vue应用中使用vue-router时出现“Error: Failed to resolve async component: xxx”怎么解决?Jun 24, 2023 pm 06:28 PM

    在Vue应用中使用vue-router是一种常见的方式来实现路由控制。然而,在使用vue-router的时候,有时候会出现“Error:Failedtoresolveasynccomponent:xxx”的错误,这是由于异步组件加载错误导致的。在本文中,我们将探讨这个问题,并提供解决方案。理解异步组件加载原理在Vue中,组件可以被同步或异步地创建

    在Vue应用中使用vue-router时出现“Error: Avoided redundant navigation to current location”怎么解决?在Vue应用中使用vue-router时出现“Error: Avoided redundant navigation to current location”怎么解决?Jun 24, 2023 pm 05:39 PM

    在Vue应用中使用vue-router时,有时候会出现“Error:Avoidedredundantnavigationtocurrentlocation”的错误信息。这个错误信息的意思是“避免了到当前位置的冗余导航”,通常是因为重复点击了同一个链接或者使用了相同的路由路径导致的。那么,怎么解决这个问题呢?使用exact修饰符在定义router

    Vue-Router: 如何使用路由元信息来管理路由?Vue-Router: 如何使用路由元信息来管理路由?Dec 18, 2023 pm 01:21 PM

    Vue-Router:如何使用路由元信息来管理路由?简介:Vue-Router是Vue.js官方的路由管理器,它可以帮助我们快速构建单页应用程序(SPA)。除了常见的路由功能外,Vue-Router还支持使用路由元信息来管理和控制路由。路由元信息是可以附加到路由上的自定义属性,它可以帮助我们实现一些特殊的逻辑或者权限控制。一、什么是路由元信息?路由元信息是

    在Vue应用中使用vue-router时出现“Uncaught TypeError: Cannot read property 'push' of undefined”怎么解决?在Vue应用中使用vue-router时出现“Uncaught TypeError: Cannot read property 'push' of undefined”怎么解决?Aug 18, 2023 pm 09:24 PM

    最近我尝试在Vue应用中使用vue-router,但遇到了一个问题:“UncaughtTypeError:Cannotreadproperty'push'ofundefined”。这个问题的原因是什么,以及如何解决呢?首先,让我们了解一下vue-router。vue-router是Vue.js官方的路由管理插件,可以帮助我们构建单页应用(SPA

    See all articles

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    AI Hentai Generator

    AI Hentai Generator

    Generate AI Hentai for free.

    Hot Article

    R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
    2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    Repo: How To Revive Teammates
    4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    Hello Kitty Island Adventure: How To Get Giant Seeds
    4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

    Hot Tools

    WebStorm Mac version

    WebStorm Mac version

    Useful JavaScript development tools

    MinGW - Minimalist GNU for Windows

    MinGW - Minimalist GNU for Windows

    This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    Atom editor mac version download

    Atom editor mac version download

    The most popular open source editor

    SublimeText3 English version

    SublimeText3 English version

    Recommended: Win version, supports code prompts!