Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data () {
- return {
- user: {
- email: '',
- password: ''
- }
- }
- }
- watch: {
- user (newValues, oldValues) {
- window.sessionStorage.setItem('userData', JSON.stringify(newValues))
- }
- }
- created () { // created hook
- const userData = window.sessionStorage.getItem('userData')
- if (userData) {
- try {
- userData = JSON.parse(userData)
- // now initiate the model
- this.user.email = userData.email
- this.user.password = userData.password
- } catch (err) {
- // userData was not a valid json string
- }
- }
- }
Add Comment
Please, Sign In to add comment