文章目录
- 1. uni.scss
- 2. store
- 3. main.js
- 4. index
1. uni.scss
$white: #FFFFFF;
$dark: #000000;.light {background: $dark;color: $white;
}
.dark {background: $white;color: $dark;
}
2. store
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)const store = new Vuex.Store({state: {vuex_theme: uni.getStorageSync('vuex_theme') ? uni.getStorageSync('vuex_theme') : 'light'},mutations: {changeTheme(state, theme) {state.vuex_theme = theme;uni.setStorageSync('vuex_theme', theme);}}
})export default store
3. main.js
import store from '@/store/index'
const app = new Vue({...App,store
})
4. index
> 直接在页面中使用
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!