V
V
Vladimir Kuts2020-10-15 09:10:53
Vue.js
Vladimir Kuts, 2020-10-15 09:10:53

Why is the variable in the dictionary not initialized?

In the data block, I initialize the dictionary

data: () => ({
            filterItem: {
                learning_type: null,
            },
...

however, learning_type remains undefined:
5f87e5b7e49e4880477628.png
why is that? And how do you set the learning_type key to null instead of undefined ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kuts, 2020-10-16
@fox_12

¯\_(ツ)_/¯
In general, I decided so far like this:

mounted() {      
      if (this.filterItem.learning_type === undefined) {
                this.filterItem.learning_type = null
       }
}

If there is a better solution, I will mark it as the answer.

B
bqio, 2020-10-15
@bqio

data() {
  return {
    filterItem: {
      learning_type: null,
    }
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question