gpt4 book ai didi

Vue.js “Maximum call stack size exceeded” 错误。为子级使用对话框并将数据从父级传递给子级失败

转载 作者:行者123 更新时间:2023-12-05 09:11:48 25 4
gpt4 key购买 nike

我正在研究 Vuetify.js,我是 Vue 的新手,我引用了这个文档 Vuetify Dialogs用于从此链接创建 Matheus Dal'Pizzol 的对话和解决方案 Open a Vuetify dialog from a component template in VueJS将其分离到组件。结果我有子组件作为对话框,如下所示

父级

    <template>
<v-container fluid>
<v-row dense>
<v-col cols="12">
<v-btn large color="success">Add product</v-btn>
</v-col>
<v-col cols="3" v-for="product in products" :key="product.id">
<v-card class="mx-auto" outlined>
<v-list-item three-line>
<v-list-item-content>
<v-list-item-title class="headline mb-1">{{product.name}}</v-list-item-title>
<v-list-item-subtitle>{{product.title}}</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-card-actions>
<v-btn dark color="cyan" @click.stop="showScheduleForm = true">
<v-icon dark>mdi-television</v-icon>
</v-btn>
<v-btn color="primary">Detail</v-btn>
</v-card-actions>
</v-card>
<modal-detail v-model="showScheduleForm" :productDetailInfo="product"></modal-detail>
</v-col>
</v-row>
</v-container>
</template>

<script>
import axios from "axios";
import ModalDetail from "./ModalDetail.vue";
export default {
name: "HelloWorld",
components: {
ModalDetail
},
data: function() {
return {
showScheduleForm: false,
products: [],
errors: []
};
},
...

child

    <template>
<v-dialog v-model="show" max-width="500" v-if="Object.keys(productDetailInfo).length !== 0">
<v-card>
<v-card-title class="headline grey lighten-2" primary-title>{{ productDetailInfo.name }}</v-card-title>

<v-card-text>{{ productDetailInfo.title }}</v-card-text>

<v-divider></v-divider>

<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="green darken-1" text @click.stop="show = false">Close</v-btn>
<v-btn color="primary">Detail</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script>
export default {
name: "ModalDetail",
props: {
productDetailInfo: {
type: Object
},
value: Boolean
},
computed: {
show: {
get() {
return this.value;
},
set(value) {
this.$emit("input", value);
}
}
}
};
</script>

但是,当我单击 icon-button“超出最大调用堆栈大小”时出现异常。似乎有一个连续的循环发生。请帮忙!我错过了什么吗?

enter image description here

最佳答案

那是因为你的v-dialogv-for循环中,很常见problem .要解决此问题,请将 :retain-focus="false" 作为 Prop 添加到您的 v-dialog

关于Vue.js “Maximum call stack size exceeded” 错误。为子级使用对话框并将数据从父级传递给子级失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59729112/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com