Guest User

Untitled

a guest
Mar 19th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. data () {
  2. return {
  3. user: {
  4. email: '',
  5. password: ''
  6. }
  7. }
  8. }
  9.  
  10. watch: {
  11. user (newValues, oldValues) {
  12. window.sessionStorage.setItem('userData', JSON.stringify(newValues))
  13. }
  14. }
  15.  
  16. created () { // created hook
  17. const userData = window.sessionStorage.getItem('userData')
  18.  
  19. if (userData) {
  20. try {
  21. userData = JSON.parse(userData)
  22.  
  23. // now initiate the model
  24. this.user.email = userData.email
  25. this.user.password = userData.password
  26. } catch (err) {
  27. // userData was not a valid json string
  28. }
  29. }
  30. }
Add Comment
Please, Sign In to add comment