English 中文(简体)
a. 选择假体的不同舱体
原标题:Different v-models for v-select in a for loop

我有这样的数据:

products: [
    {
      name: "Camera",
      subProducts: [
         {
          name: "Type",
          types: [
             {
              name: "CAM A",
              value: "A",
             },
             {
              name: "CAM B",
              value: "B",
             },
           ],
          },

          {
           name: "Recorder",
           types: [
             {
              name: "Yes",
              value: 1,
             },
             {
              name: "No",
              value: 0,
             },
            ],
           },

          ],
        },

我想根据子产品的数量来挑选一些选修课。 每一当选者都将展示一个类型的群体。

举例来说,在第一个阶段,你可以在南极海委会A/南极海委会B之间挑选2名候选人。 在第二种情况下,你可以选择是/否。

computed: {
 comModels: function () {
  for (let i = 0; i < this.products.length; i++) {
    if (this.products[i].name == this.selectedMainGroup) {
      return this.products[i].subProducts;
    }
  }
  return "nothing";
 },
},

这是我对以下方面的真心所料:

          <v-select
            v-for="product in comModels"
            :itemProps="itemProps"
            v-model="selectedModel"
            :items="product.types"
            :label="product.name"
            dense
            solo
            outlined
            hide-details
            class="ma-2"
          >
          </v-select>

问题在于,我只选择其中一人,而另一人则被删除。 我如何能够保持其价值观,同时保持灵活性,因为可能有更多的分门别类。

问题回答

选择的单体字体需要独立,然后将选定的模型改为目标,并使用v-model=“选择的Model[产品名称]”。

data(){
        return {
            selectedModel:{}
        }
    }

...
 <v-select
            v-for="product in comModels"
            :itemProps="itemProps"
            v-model="selectedModel[product.name]"
            :items="product.types"
            :label="product.name"
            dense
            solo
            outlined
            hide-details
            class="ma-2"
          >
          </v-select>




相关问题
Nuxt 3 useRoute import cannot find

I am using latest nuxt version and when I tried to use the useRoute method is triggers a "Cannot Find name useRoute" but it works so I would like to know what could I be missing My package ...

Vue array dependent select not display data

I have dependent selection like this. Selection image when i console log, they have data but not render data in selection data This is what i ve tried. for Product selection has default selected value ...

How to inject Bearer Token in Axios boot file

Quasar has a different setup using boot files and my current axios.ts looks liek this: import { boot } from quasar/wrappers ; import axios, { AxiosInstance } from axios ; declare module @vue/...

Vue router and Vite Base url conflict

I use Vue Router to develop my single page application and use Vite to package my project. I want to deploy all static files (such as index.js and index.css) under another CDN domain name (cdn.example....

Vue.js change class on mounted

I have a button element with a .hover property and I need the hover animation to also happen as soon as the page is mounted. How can I attribute a class to a button on the mounted function and then ...

Laravel +Vuejs CORS issue

I am facing a dilemma wit the CORS issue. I have application that is configured as follow: API: https://abc.mydomain.com (laravel) front end: https://subdomain.mydomain.com(VueJS) Both applications ...

热门标签