I have a Vue.js form filter:
I have a methods to get the input and selected values:
methods: { changeFilter() { console.log(this.name, this.gender) }, }, Now I want to reload the page but the input box or select box still shows the value I selected. please help me. Thank you
Okay, so the first good practice is not to use cangeFilter() on the click event, but to use changeFilter. So if I understand you correctly, you want to reload the page and still have the same value selected. You can save this value in local storage, assuming it's not sensitive data.
Local storage informationSave data in local storage
localStorage.setItem('gender', 'Male');Get data (you need to use a life cycle hook like mounted to initialize the data)
mounted() { this.gender = localStorage.getItem('gender') || '你的默认值'; }Values in HTML input form