I want to use some of the constants defined in state to assign default values to the drop-down box and v-model this variable in the data of the component, what should I do?

I"m going to assign the default value of 1 to the value of the drop-down box and bind this variable;

<select v-model="selectValue"></select>

but just let

data(){
   return{ selectValue:1 }
}

this type of writing is not readable, so I want to declare a constant, because many pages use this constant,
, so I put it in the state of vuex;

state: {
    // 
    SINGLE_GAME: 1
}

then I introduce state,data directly into the component

data(){
   return{ selectValue:this.SINGLE_GAME }
}

this way of writing is more readable;

but cannot assign a value to selectValue, but in

created()
Print

in

method

this.SINGLE_GAME

but you can print out the value;

then I don"t know what to do,

because I"m going to use

v-model

bind this variable, so you should not use

computed

,


The value of computed cannot be taken in

data () , because computed depends on data

but in created () , both data and computed are ready, so you can assign it manually in created:

created () {
  this.selectValue = this.SINGLE_GAME
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf09b0-4629f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf09b0-4629f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?