Home>

my input associated V-model and stored in the local component variable. And I need to access this local variable in the Vuex itself, how can this be done? I repeat, not to get data from Vuex into the component, but on the contrary, get from the component to Vuex itself. Tell me how can this be implemented?

It takes it to tighten the data from the input to the $ {} string.

await fetch (`https://min-api.cryptocompare.com/data/price?fsym=BTC&
tsyms= $ {} `)

Data in Vuex is transmitted by actions and mutations. To receive some local values ​​from global storage -it is not necessary, this is a rough error with extremely extremely negative effects. All that should be used in the actions, put in stor through mutations ... This is the only right way to Vuex.

yar852021-07-21 19:05:37

Well, if the data is used not to actions, but only in one action -give these data with Payload (it is quite obvious, it seems, but just in case I will write).

yar852021-07-21 19:14:20

@ YAR85 I need not to get from the storage in the component, but the opposite from the component get access in the storm itself, so that I could substitute this value tsyms= $ {here} `)

salco2020202021-07-21 19:53:10

So you need to stop using Vue and Vuex at all, due to the contradiction of the needs of the ideology of these libraries. But there will be nothing to replace them -because What you need, it seems like everywhere is considered antipattern.

yar852021-07-21 19:55:02

@ yar85 Why? All data will mostly come out to the overall stor, but my input is associated with a local variable, can't I put it in Vuex?

salco2020202021-07-21 19:59:51
  • Answer # 1

    Make a computed property and procin it in the Input. In action, register the data in Stor and Fetch Dergay.

    Value: {
       get () {
           Return this. $ store.state.value
       }
       SET (Value) {
           This. $ Store.Dispath ('values', value)
       }
    }
    
  • Answer # 2

    Make a computed property and procin it in the Input. In action, register the data in Stor and Fetch Dergay.

    Value: {
       get () {
           Return this. $ store.state.value
       }
       SET (Value) {
           This. $ Store.Dispath ('values', value)
       }
    }