VUE APOLLO查询错误模块构建失败

发布于 2025-01-30 01:44:37 字数 2072 浏览 5 评论 0原文

因此,基本上,我想在VUE 2 CLI中使用Apollo查询进行查询。但这是不起作用的,我不知道有什么问题。也许有人可以帮助我?我已经坚持3个小时,

这是代码

<ApolloQuery
          :query="
            (gql) => gql`
              query MyQuery {
                fasilitas {
                  judul
                  judul_second
                  deskripsi
                  foto
                }
              }
            `
          "
        >
          <template v-slot="{ result: { loading, error, data } }">
            <div v-if="loading" class="loading apollo">Loading...</div>

            <div v-else-if="error" class="error apollo">An error occurred</div>

            <div v-else-if="data" class="result apollo">{{ data.fasilitas }}</div>

            <div v-else class="no-result apollo">No result :(</div>
          </template>
        </ApolloQuery>

,这是错误

ERROR  Failed to compile with 1 error                                                                                           01:44:40

 error  in ./src/views/IndexView.vue?vue&type=template&id=78027b66&

Syntax Error: Error
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)


ERROR in ./src/views/IndexView.vue?vue&type=template&id=78027b66& (./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/IndexView.vue?vue&type=template&id=78027b66&)
Module build failed (from ./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js):
Error
    at Node.initialise (D:\PNJ\Kampus Merdeka\Alterra Academy\vue_mini-project_roland-brilianto\node_modules\vue-template-es2015-compiler\buble.js:16016:10)
    at D:\PNJ\Kampus Merdeka\Alterra Academy\vue_mini-project_roland-brilianto\node_modules\vue-template-es2015-compiler\buble.js:7993:51
    at Array.forEach (<anonymous>)
webpack compiled with 1 error

so basically i want to do a query using Apollo Query in Vue 2 CLI. but it is not working, i dont know what is the problem. maybe someone can help me? i have stuck for 3 hours withour any progress

here is the code

<ApolloQuery
          :query="
            (gql) => gql`
              query MyQuery {
                fasilitas {
                  judul
                  judul_second
                  deskripsi
                  foto
                }
              }
            `
          "
        >
          <template v-slot="{ result: { loading, error, data } }">
            <div v-if="loading" class="loading apollo">Loading...</div>

            <div v-else-if="error" class="error apollo">An error occurred</div>

            <div v-else-if="data" class="result apollo">{{ data.fasilitas }}</div>

            <div v-else class="no-result apollo">No result :(</div>
          </template>
        </ApolloQuery>

and here is the error

ERROR  Failed to compile with 1 error                                                                                           01:44:40

 error  in ./src/views/IndexView.vue?vue&type=template&id=78027b66&

Syntax Error: Error
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)
    at Array.forEach (<anonymous>)


ERROR in ./src/views/IndexView.vue?vue&type=template&id=78027b66& (./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/IndexView.vue?vue&type=template&id=78027b66&)
Module build failed (from ./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js):
Error
    at Node.initialise (D:\PNJ\Kampus Merdeka\Alterra Academy\vue_mini-project_roland-brilianto\node_modules\vue-template-es2015-compiler\buble.js:16016:10)
    at D:\PNJ\Kampus Merdeka\Alterra Academy\vue_mini-project_roland-brilianto\node_modules\vue-template-es2015-compiler\buble.js:7993:51
    at Array.forEach (<anonymous>)
webpack compiled with 1 error

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长安忆 2025-02-06 01:44:37

我在同一问题上挣扎。您必须将标签设置添加到vue.config.js。

https://apollo.vuejs.s.s.s.s.s.s.s.s.s.org/guide/guide/components/querponet/query。 html#tag-stup

i struggled with the same issue. you have to add the tag setup to your vue.config.js.

https://apollo.vuejs.org/guide/components/query.html#tag-setup

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文