Javascript 如何在vuex中定义状态变量 计算:{ 日期范围(){ 返回[ {text:i18n.t('Latest'),范围:[null,null]}, {text:i18n.t('Hour'),范围:[-3600,null]}, {text:i18n.t('SevenHours'),范围:[-3600*6,null]}, {text:i18n.t('TwentyHours'),范围:[-3600*12,null]}, {divider:true}, {text:i18n.t('SelectRange'),范围:[0,0]}, ] }, isDark(){ 返回此。$store.getters.getPreference('isDark')) }, 历史(){ 返回this.item.history.map((h,index)=>({index:index,…h})) }, 当前系统(){ 返回此。$store.getters['alarms/systems'] }, 过滤器系统:{ 得到(){ 返回此项。$store.state.alarm.filter.system }, 设置(值){ 此.$store.dispatch('alarms/setFilter'{ 系统:value.length>0?值:空 }).然后(()=>这个.$store.dispatch('alarms/getAlamrs')) } },

Javascript 如何在vuex中定义状态变量 计算:{ 日期范围(){ 返回[ {text:i18n.t('Latest'),范围:[null,null]}, {text:i18n.t('Hour'),范围:[-3600,null]}, {text:i18n.t('SevenHours'),范围:[-3600*6,null]}, {text:i18n.t('TwentyHours'),范围:[-3600*12,null]}, {divider:true}, {text:i18n.t('SelectRange'),范围:[0,0]}, ] }, isDark(){ 返回此。$store.getters.getPreference('isDark')) }, 历史(){ 返回this.item.history.map((h,index)=>({index:index,…h})) }, 当前系统(){ 返回此。$store.getters['alarms/systems'] }, 过滤器系统:{ 得到(){ 返回此项。$store.state.alarm.filter.system }, 设置(值){ 此.$store.dispatch('alarms/setFilter'{ 系统:value.length>0?值:空 }).然后(()=>这个.$store.dispatch('alarms/getAlamrs')) } },,javascript,python,vue.js,vuex,vuetify.js,Javascript,Python,Vue.js,Vuex,Vuetify.js,} 我有板条箱系统[]在getters action and mutation中的状态和方法中…但无法获取v-select组件中的数据。我更新了一些计算属性…我观看了一些教程…在教程中,他们仅使用方法或仅使用方法您是否尝试过使用mapState并像那样从存储访问系统值? 您可以在此链接上找到一个示例: 将其添加到组件中: <v-select v-model="filterSystem" :items="currentSystems"

}


我有板条箱系统[]在getters action and mutation中的状态和方法中…但无法获取v-select组件中的数据。我更新了一些计算属性…我观看了一些教程…在教程中,他们仅使用方法或仅使用方法

您是否尝试过使用mapState并像那样从存储访问系统值? 您可以在此链接上找到一个示例:

将其添加到组件中:

<v-select
          v-model="filterSystem"
          :items="currentSystems"
          :menu-props="{ maxHeight: '400' }"

          class="pa-0 ma-0"
          multiple
          outline
          dense

          persistent-hint
        />


 computed:{
dateRanges() {
  return [
    { text: i18n.t('Latest'), range: [null, null] },
    { text: i18n.t('Hour'), range: [-3600, null] },
    { text: i18n.t('SevenHours'), range: [-3600 * 6, null] },
    { text: i18n.t('TwentyHours'), range: [-3600 * 12, null] },
    { divider: true },
    { text: i18n.t('SelectRange'), range: [0, 0] },
  ]
 },
isDark() {
  return this.$store.getters.getPreference('isDark')
},
 history() {
  return this.item.history.map((h, index) => ({ index: index, ...h }))
},
 currentSystems() {
  return this.$store.getters['alarms/systems']
},
filterSystem: {
  get() {
    return this.$store.state.alarm.filter.system
  },
  set(value) {
    this.$store.dispatch('alarms/setFilter', {
      system: value.length > 0 ? value : null
    }).then(() => this.$store.dispatch('alarms/getAlamrs'))
  }
 },
然后,您的v-select应该如下所示:

import { mapState } from 'vuex'

computed: {
           ...mapState('alarms', ['systems'])
        },


我正在开发web应用程序…其中包含大量数据…和文件…我没有看到任何mapState…一个文件夹为store have module,模块文件夹为many store file。web应用程序已经包含2个筛选器,但我想为该应用程序再做一个筛选器…因此,通过此操作,我有declaredconst state={systems:[],filter:{system:null},const mutations={SET_systems(state,systems):any{state.systems=systems},const actions={getSystems({commit}){return AlarmsApi.getSystems({})。然后({systems})=>commit('SET_SYSTEMS',SYSTEMS))},const getters={SYSTEMS:state=>{return state.SYSTEMS.map(r=>r.system.sort()}事实上,我是vuejs和vuex的新手…所以我只是暂时搁置了商店和web应用中已经定义的以前的过滤器。这就是为什么有些地方我在系统中使用s,而有些地方没有s。你能用你在评论中输入的代码更新你的问题吗?我建议使用mapState,因为这是一种从e组件,不管你以前是否使用过它,在我发布的链接上有很好的解释。不起作用…我已经应用了你编写的上述代码
        <v-select
          v-model="filterSystem"
          :items="systems"
          :menu-props="{ maxHeight: '400' }"
          class="pa-0 ma-0"
          multiple
          outline
          dense
          persistent-hint
        />