forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: [SSR] Cannot use set() or clear() with LocalStorage on client side
- Loading branch information
1 parent
c2f7beb
commit fe11a45
Showing
4 changed files
with
82 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<template> | ||
<div class="layout-padding"> | ||
<div>{{ storage }}</div> | ||
<q-btn-group> | ||
<q-btn label="Toggle test1" @click="toggle('test1')" /> | ||
<q-btn label="Toggle test2" @click="toggle('test2')" /> | ||
<q-btn label="Toggle test3" @click="toggle('test3')" /> | ||
<q-btn label="Clear" @click="clear" /> | ||
</q-btn-group> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { LocalStorage } from 'quasar' | ||
export default { | ||
data () { | ||
return { | ||
storage: LocalStorage.get.all() | ||
} | ||
}, | ||
methods: { | ||
toggle (key) { | ||
if (LocalStorage.has(key)) { | ||
LocalStorage.remove(key) | ||
} | ||
else { | ||
LocalStorage.set(key, `${key}-value`) | ||
} | ||
this.update() | ||
}, | ||
clear () { | ||
LocalStorage.clear() | ||
this.update() | ||
}, | ||
update () { | ||
this.storage = LocalStorage.get.all() | ||
} | ||
}, | ||
mounted () { | ||
this.$nextTick(() => { | ||
this.update() | ||
}) | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="stylus"> | ||
@import '~variables' | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters