javascript - How does vue get the parameter value in the url?
我想大声告诉你
我想大声告诉你 2017-05-19 10:36:06
0
3
1244

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")

After running, the console reports an error

我想大声告诉你
我想大声告诉你

reply all(3)
阿神

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 object

const routes = [
  {path : '/portfolio/:year/review', component : Portfolio }
];

Get it like this

this.$route.params.year
this.$route.query.id
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template