0👍
✅
Achieved the results by using localStorage
.
<script>
export default {
components: {},
data() {
return {
errors: [],
state: localStorage.getItem('state'),
country: localStorage.getItem('country'),
terms: localStorage.getItem('terms'),
countries: [{
name: 'Afghanistan',
code: 'AF'
},
{
name: 'Åland Islands',
code: 'AX'
},
...
]
}
},
methods: {
submit: function(e) {
this.errors = [];
if (!this.state) {
this.errors.push('State is required!');
}
if (!this.country) {
this.errors.push('Country is required!');
}
if (!this.terms) {
this.errors.push('You need to accept the terms!');
}
if (this.errors.length == 0) {
console.log(this.country,this.state,this.terms);
let terms_of_use = {'country': this.country, 'state': this.state, 'terms': this.terms};
localStorage.setItem('country', this.country);
localStorage.setItem('state', this.state);
localStorage.setItem('terms', this.terms);
this.$router.push("details")
}
},
dismiss: function(e) {
this.errors = [];
}
}
}
</script>
Source:stackexchange.com