1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| import Vue from 'vue'
|
| const state = new Vue({
| data: {
| theme: 'black'
| },
| methods: {
| toggleTheme: function () {
| this.theme = (this.theme === 'black' ? 'red' : 'black')
| window.localStorage.setItem('vue-liang-rong-wap-theme', JSON.stringify({data: this.theme}))
| }
| },
| created: function () {
| const theme = JSON.parse(window.localStorage.getItem('vue-liang-rong-wap-theme'))
| if (theme && theme.data) {
| this.theme = theme.data
| }
| }
| })
|
| export default state
|
|