A
A
Artem00712017-09-12 12:19:46
Vue.js
Artem0071, 2017-09-12 12:19:46

Why is Vuex so weird?

I use Vuex and element.io
There is a dialog box
It has a visible parameter, if true, then the window is shown

<el-dialog
    title="Tips"
    :visible="dialogVisible"
    size="tiny"
    :before-close="handleClose">
    <span>This is a message</span>
    <span slot="footer" class="dialog-footer">
    <el-button @click="handleClose">Cancel</el-button>
    <el-button type="primary" @click="handleClose">Confirm</el-button>
  </span>
  </el-dialog>

Vuex has a state:
state: {
    visible_settings: false
  },

Tried to pass the state like this in the component:
return this.$store.state.visible_settings
But it didn't work . It
only worked when I created a separate getter in vuex:
getVisibleSettings: state => {
      return state.visible_settings;
    }

And accordingly in the component:
return this.$store.getters.getVisibleSettings
Why did it happen? After all, they are essentially the same thing. In the first case and in the second, I simply give the variable

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question