javascript - How does vue get the parameter value in the url?
我想大声告诉你2017-05-19 10:36:06
0
3
1150
1. Create the geturlpara.js file
2. Register the global method in main.js import geturlpara from './geturlpara.js' Vue.prototype.$geturlpara = geturlpara 3.var mid = this.$geturlpara.getUrlKey("mid")
There is a url parser in nodejs, and there is a .route attribute in vue instance, both of which can get the link parameters. If you can’t encapsulate a js method, you can also do it, or directly search on Baidu, there are a lot of ready-made ones Your error is still xxx.[ 1] problem, if the returned array is empty or [''], your [1] === undefined undefined.replace() will naturally report an error
Write step 3 into the vue component file to get the parameter values
There is a url parser in nodejs, and there is a .route attribute in
vue instance, both of which can get the link parameters.
If you can’t encapsulate a js method, you can also do it, or directly search on Baidu, there are a lot of ready-made ones
Your error is still xxx.[ 1] problem, if the returned array is empty or [''], your [1] === undefined
undefined.replace() will naturally report an error
If you are using
vue-router
the documentation is here Properties of the routing information objectGet it like this