组件渲染函数Vuejs中的无限更新循环

时间:2019-11-09 07:16:18

标签: vue.js

当我尝试将选定的数据推入数组时显示

  

组件渲染函数中的无限更新循环。

错误。我尝试了类似的答案,但是没有用。

                    <v-select v-for="(orderCategory, k) in orderCategories"
                              :items="orderCategory.items"
                              :label="orderCategory.name"
                              v-model="selectedCatAddon[orderCategory.id]"
                              @change="selectCatOption(orderCategory,selectedCatAddon[orderCategory.id])"
                              item-text="name"
                              return-object
                              :key="'B'+k"

                    > </v-select>

脚本部分...

selectCatOption(selectedorderCategory, selectedAddon) {

            if (selectedorderCategory && selectedAddon) {
                let model = {
                    'id': selectedAddon.id,
                    'name': selectedAddon.name,
                    'category': selectedorderCategory,
                    'primary': selectedAddon.primary,
                    'loyalty_price': selectedAddon.loyalty_price,
                    'price_type': selectedAddon.price_type,
                    'price': selectedAddon.price,
                    'discount': selectedAddon.discount,
                    'discount_special': selectedAddon.special_discount,
                };


                let found = this.selectedFeatureArray.find(product => product.category === model.category);
                console.log(found);
                if (found) {
                    let deleting = this.selectedFeatureArray.findIndex(product => product.id === model.id);
                    this.selectedFeatureArray.splice(deleting, 1);
                }
                this.selectedFeatureArray.push(model);
            }
        }

0 个答案:

没有答案