How do I pass parameters to the function in Vue mounted ()?

if I have a link http://127.0.0.1:8080?jh=xx, when I click on this link, pass the parameter xx to another Vue page in the mounted method

mounted(){
    this.getData(jh),
}

in other words, this page initially depends on the method in mounted to get the data to render the page, but it needs a parameter, how can it be passed in

Jul.13,2022

mounted () {
   this.getData(this.$route.query.jh)
}

https://www.jb51.net/article/...
article enumerates three ways of passing parameters, hoping to help you


two methods
1, return this parameter from the route, this.$route.query.jh, written by a brother above.
2. Parse directly in location.href and get it from the connection with regular expressions.


mounted () {

this.getData(this.$route.params.id)

}


in addition to taking from the url parameters as mentioned above, you can also pass parameters in the upper props, so you can also use

in mouted.

if it helps you, please upvote or adopt ~

Menu