desc
A public method used to two-way computed property support modules
api
mapStateModelValuesInStrict
will commit a mutation with valuemapStateModelValuesInStrictWithPayload
will commit a mutation with payload
use
- simple
// single, you can pass a get function // mapStateModelValuesInStrict(modelValue, stateName, mutationType[, {getFn}]) computedProps = /** computedProps = { test: { get: function(){ return this.$store.state.test }, set: function(value){ this.$store.commit('updateTest', value) } } } */
- commit mutation with payload
// commit with payload computedProps = /** computedProps = { test: { get: function(){ return this.$store.state.test }, set: function(value){ this.$store.commit('updateTest', { test: value }) } } } */
- get with custom function
let { return stateobjmsg } computedProps = /** computedProps = { test: { get: function(){ return getFn(this.$store.state, 'test', 'test') }, set: function(value){ this.$store.commit('updateTest', value) } } } */
- mutiple
//GetFn1 has a higher priority than getFn let { } computedProps = /** computedProps = { test: { get: function(){ return getFn1(this.$store.state, 'testModel', 'test') }, set: function(value){ this.$store.commit('updateTest', value) } }, info: { get: function(){ return getFn(this.$store.state, 'info', 'info') }, set: function(value){ this.$store.commit('updateInfo', value) } } } */
- you can set modulePath in opts
computedProps = /** computedProps = { test: { get: function(){ return this.$store.state.form.test }, set: function(value){ this.$store.commit('form/updateTest', value, {root: true}) } }, info: { get: function(){ return this.$store.state.form.obj.test }, set: function(value){ this.$store.commit('form/obj/updateInfo', value, {root: true}) } } } */
- you can use getFn for modules
let { if moduleName === 'testModel' return stateformupdateTest if moduleName === 'info' return stateformobjinfo } computedProps = /** computedProps = { test: { get: function(){ return getFn2() }, set: function(value){ this.$store.commit('form/updateTest', value) } }, info: { get: function(){ return getFn2() }, set: function(value){ this.$store.commit('form/obj/updateInfo', value) } } } */
- mixin result to computed
const config = computed: //.....some computed methods Object