-1

只是一个简单的问题,我正在使用 VueJS 3 和 VueX 状态管理。

app.config.globalProperties.store_id = '5f82da561622f55328d8baac'

这是我使用的全局属性,想知道如何使用 VUEX 直接访问它。

https://v3.vuejs.org/api/application-config.html#globalproperties

4

1 回答 1

1

您可以将其定义store_id为商店中的状态,可以在商店以及您想要的任何组件中使用:

import { createStore } from 'vuex'

// Create a new store instance.
const store = createStore({
  state () {
    return {
      store_id: '5f82da561622f55328d8baac',
     //other state
    }
  },
  mutations: {
  
  }
})
于 2021-01-10T13:25:46.787 回答