Pinia InternalError:在 Quasar 中使用 q-list 时出现太多递归错误
P粉262073176
P粉262073176 2023-09-01 20:26:11
[Vue.js讨论组]
<p>在我的 Quasar 组件中使用 Pinia Store 时,我遇到了这个错误 <code>InternalError: Too much recursion</code>,我已经做了我所知道的一切但没有解决。</p><p> 我可以在这里得到建议吗?</p> <p>这是我的 <code>IndexPage.vue</code>,我在其中调用 QList 组件:</p> <pre class="brush:php;toolbar:false;">&lt;template&gt; &lt;q-page&gt; &lt;div class=&quot;q-pa-md&quot; style=&quot;max-width: 350px&quot;&gt; &lt;QList /&gt; &lt;/div&gt; &lt;/q-page&gt; &lt;/template&gt; &lt;script&gt; import QList from 'src/components/QList.vue'; export default { components: { QList } } &lt;/script&gt;</pre> <p>这是我的 <code>QList.vue</code> 组件:</p> <pre class="brush:php;toolbar:false;">&lt;template&gt; &lt;div v-if=&quot;loading&quot;&gt;Carregando...&lt;/div&gt; &lt;q-list v-else bordered separator&gt; &lt;q-item v-for=&quot;item in testData&quot; :key=&quot;item.id&quot; clickable v-ripple&gt; &lt;q-item-section&gt;{{ item.title }}&lt;/q-item-section&gt; &lt;/q-item&gt; &lt;/q-list&gt; &lt;/template&gt; &lt;script&gt; import { testeStore } from '../stores/teste' import { defineComponent, computed, onMounted } from 'vue'; export default defineComponent({ setup () { const store = testeStore(); onMounted(() =&gt; { store.loadData(); }); const testData = computed(() =&gt; store.getData()); const loading = computed(() =&gt; store.$state.loading); return { testData, loading } } }) &lt;/script&gt;</pre> <p>还有我的 <code>testeStore.js</code> 商店:</p> <pre class="brush:php;toolbar:false;">import { defineStore } from 'pinia' import testeData from '../assets/data/testes.json' export const testeStore = defineStore({ id: 'teste', state: () =&gt; ({ data: [], loading: false, }), getters: { getData: state =&gt; state.data, }, actions: { loadData () { try { this.loading = true this.data = testeData; } catch (error) { console.log(`Error fetching testes: ${{ error }}`) } finally { this.loading = false } } } })</pre> <p>每个组件看起来都很正常,我真的不知道我的问题出在哪里。 这是来自控制台的一段 vue warn:</p> <pre class="brush:php;toolbar:false;">[Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt; at &lt;QList key=1 bordered=&quot;&quot; separator=&quot;&quot; &gt;</pre></p>
P粉262073176
P粉262073176

全部回复(1)
P粉547170972

刚刚检查了 stackblitz,看起来您自己的 QList 组件和 Quasar 的内置“q-list”组件之间存在命名冲突。 Vue 对待组件名称不区分大小写,这就是为什么它将“q-list”和“QList”解释为同一个组件。

要解决此问题,您可以尝试将自己的 QList 组件重命名为与 Quasar 组件不冲突的其他名称,例如“MyQList”,或者使用别名导入 Quasar“q-list”组件。

从 'quasar' 导入 { Qlist as QuasarList }

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号