在 Vue-apollo 中使用 gql-tag 构造查询字符串

我相信可以用 JS 动态构造 GraphQL 查询字符串,但我无法弄清楚语法。 我的 Vue 组件中有一个查询,如下所示:

  apollo: {
    metricsOee: {
      query: METRICS_OEE,loadingKey: 'loading',variables() {
        return {
          widgetType: this.data.name,page: 'dashboard',currentMetricDay: this.currentTime
        }
      }
    }
  }

我不想每次都从我的组件传递 currentTime,而是在查询本身中计算它。我这样做的尝试看起来像这样:

[![在此处输入图片描述][1]][1]

我理解 gql`` 和 JS 插值不一样,但这是为了说明问题
[1]:https://i.stack.imgur.com/qwgpw.png

lmzml 回答:在 Vue-apollo 中使用 gql-tag 构造查询字符串

您可能需要用双引号将 agDateInput 括起来:

agDateInput
本文链接:https://www.f2er.com/1102466.html

大家都在问