For Example I have this
mounted () {
this.$router.push({
path: '/activatewithphone',
query: { serial: this.$route.params.serial, machine: this.$route.params.machine }
})
},
This means whenever a user visits a URL like this
http://example.com/activate?serial=sddsdsds&machine=sdsdsd
The user will not be shown a 404 page.
The value of serial and machine is dynamic and can be anything.
My question is there a way to take the values and store its data on mounted
e.g
data: () => {
return {
serial: '',
email: '',
}
},
Can I take the value and assign it to a my serial and email variables, maybe using this.serial
Advertisement
Answer
You could use computed property:
computed: {
serial() {
return this.$route.query.serial
},
email() {
return this.$route.query.email
}
}