【问题标题】:Google Tag Manager API example throwing "Uncaught RangeError: Maximum call stack size exceeded" error in consoleGoogle Tag Manager API 示例在控制台中抛出“Uncaught RangeError: Maximum call stack size exceeded”错误
【发布时间】:2017-12-01 16:34:43
【问题描述】:

我从这个 Google Tag Manager API 文档中获取了“完整示例”的代码:

https://developers.google.com/tag-manager/api/v2/devguide#example

我将 TODO 更改为我的客户 ID,并更新了 ACCOUNT_PATHCONTAINER_NAMEWORKSPACE_NAME,但是当我运行它时,我只是在控制台中看到一个空白页面。

我缺少哪些步骤?如果有影响的话,我也会在 localhost 上运行该文件。

【问题讨论】:

    标签: javascript api google-api google-tag-manager


    【解决方案1】:

    这是因为第 47 行的 checkAuth() 函数在递归循环中调用自身。

    我通过更改调用函数的名称来修复它-

    function checkAuthVal(immediate) {
      var authorizeCheckPromise = new Promise((resolve) => {
        gapi.auth.authorize(
          { client_id: CLIENT_ID, scope: SCOPES.join(' '), immediate: immediate },
          resolve);
      });
      authorizeCheckPromise
          .then(handleAuthResult)
          .then(loadTagManagerApi)
          .then(runTagManagerExample)
          .catch(() => {
            console.log('You must authorize any access to the api.');
          });
    }
    
    /**
     * Check if current user has authorization for this application.
     */
    function checkAuth() {
      checkAuthVal(true);
    }
    

    这行得通!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-25
      • 1970-01-01
      相关资源
      最近更新 更多