配置
在 Nuxt.js 下的 Vuex 已经标准依赖 store/index.js 这个文件作为 Vuex 的配置
export const state = () => ({id: 0});export const mutations = {selectTab (state, id) {state.id = id;}}
使用
直接 this.$store
<script>export default {// ...methods: {onTabClick(id) {this.$store.commit('selectTab', id);}}}</script>
