0
Hi, I’m new with vuex and I need a little help:
below is a piece of my code:
<v-btn icon color="purple darken-2" @click="addKeyNames"
><v-icon> mdi-plus-circle-outline</v-icon>
</v-btn>
</v-col>
</v-row>
<v-row v-for="(keyNamesLocal, index) in keyName" v-bind:key="index">
<v-col id="chave" cols="12" md="4">
<ValidationProvider
v-slot="{ errors }"
name="Nome da Chave"
rules="required|max:100"
required
>
<v-text-field
v-model="keyNamesLocal.name"
label="Nome da Chave"
:error-messages="errors"
:counter="100"
required
/>
</ValidationProvider>
</v-col>
<v-col id="chave" cols="12" md="1">
<v-btn
icon
large
color="purple darken-2"
@click="removeKeyName(index)"
>
<v-icon>mdi-delete-forever-outline</v-icon>
</v-btn>
vuex:
export default new Vuex.Store({
strict: true,
state: {
api: {
id: "",
name: "",
description: "",
developer: "",
legacy: "",
endpoint: "",
releaseDate: "",
project: "",
keyNames: [],
uraType: "",
xmlOutput: "",
xmlInput: "",
codeReturn: "",
descriptionReturn: "",
errorTypeReturn: "",
xmlCodeReturn: "",
segmentation: ["Controle", "Pós", "Pré", "Next", "Nenhuma"],
attachment: [],
},
},
mutations: {
UPDATE_API(state, payload) {
state.api = Object.assign(state.api, payload);
},
createKeyName(state, payload) {
state.api.keyNames = payload
},
I need my text-field label: Key Name, record keys inside my array (api.keyNames in store), but it is returning an error.
Error in callback for Watcher "Function () { Return this. _data. $$state }": "Error: [vuex] do not mutate vuex store state Outside Mutation handlers."
I appreciate the explanation and help Germano, but I don’t think I expressed myself correctly. What I actually need is to capture user names(strings) and save in my keyNames array that is in my parent object (api) within my store. It would push into an array of strings
– Bruno Perin