单独对象中的Vue.JS / Vuetify动态v模型是相同的

时间:2018-07-20 14:10:42

标签: vue.js vuejs2 vuetify.js

我正在尝试使用动态v模型(与源使用相同的数组)进行输入。

问题在于,以某种方式运行时,即使在单独的对象中,变量子设置在所有对象上都相同。 因此,以某种方式我将其静态化而又不想,有人能发现我要去哪里了吗?

<div v-for="(row, rowIndex) in inputRows" :key="rowIndex">
  <v-autocomplete
  :items="tags"
  v-model="inputRows[rowIndex].tags"
  :label="'Lägg till'"
  item-text="tag"
  return-object
  multiple
  ></v-autocomplete>
     <v-list v-if="row.tags.length > 0">
        <v-card
        v-for="(tag, tagIndex) in row.tags"
        v-if="tag.type == 'array' 
        && checkIfObjectArray(tag, data[chosenDataset])"
        :key="tagIndex"
        style="padding-top: 10px; padding-bottom: 10px; padding-left: 100px">
           <v-card-text>
              <div>
                 <v-autocomplete
                 :items="getArrayTags(data[chosenDataset],tag.tag)"
                 v-model="inputRows[rowIndex].tags[tagIndex].subSettings"
                 :label="`Vad ska visas från ${tag.tag}?`"
                 item-text="tag"
                 return-object
                 multiple
                 ></v-autocomplete>
              </div>
           </v-card-text>
           <div v-if="tag.type == 'object'">
             {{tag.tag}} == Object
           </div>
        </v-card>
     </v-list>
  </div>

我从添加几行得到的输出:

// console.log(JSON.stringify(inputRows, null, 4))
 [
{
    "tags": [
        {
            "tag": "coworkers",
            "type": "array",
            "subSettings": [
                {
                    "tag": "name",
                    "type": "string"
                },
                {
                    "tag": "hired",
                    "type": "string"
                },
                {
                    "tag": "workplace",
                    "type": "string"
                }
            ]
        }
    ]
},
{
    "tags": [
        {
            "tag": "coworkers",
            "type": "array",
            "subSettings": [
                {
                    "tag": "name",
                    "type": "string"
                },
                {
                    "tag": "hired",
                    "type": "string"
                },
                {
                    "tag": "workplace",
                    "type": "string"
                }
            ]
        }
    ]
}

]

0 个答案:

没有答案