I'm trying to do is pass an array from query to the backend using Vue.js and router.
So I have this method:
submitForm () {
this.$router.push({
name: 'AuctionResult',
query: {
models: this.selectedModels.map(e => e.value)
}
})
},
As a result will be query like this: ?models=MODEL1&models=MODEL2...
But how can I make inputs look like array, like this: ?models[]=MODEL1&models[]=MODEL2...
???
I didn`t find anything in the documentation.
To support PHP / array style multi-values, you can just set the key name to be what you want, ie
query: {
'models[]': this.selectedModels.map(e => e.value)
}
This may come out as
?model%5B%5D=MODEL1&model%5B%5D=MODEL2...
but that's fine (it's just URL encoded) and your server-side request handler should decode it correctly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.