我正在尝试在对象存储中保存对象数组。
我已经
export interface Validation {
name: string,
type: string,
value?: string
}
export interface MyStoreObject {
name: string,
validations?: Array<Validation>,
}
我正在尝试将我的对象保存为带有突变的数组:
SET_VALIDATION(state, payload: any) {
Vue.set(state._[payload.key], 'validations', [...payload.payload]);
}
In my compoment i've this function:
addValidation() {
console.log('addValidation');
const value: Validation = {
name: this.validationType,
type: this.validationType,
value: this.validationValue,
};
this.$store.commit('SET_VALIDATION', {
key: this.attributeKey,
value,
});
}
有什么想法吗?