Polymer 1.0: What could be causing this error? "Uncaught TypeError: this is not a function"

Polymer 1.0: What could be causing this error? "Uncaught TypeError: this is not a function"

问题

What could be causing the following console error?

Uncaught TypeError: this.$.authgoogle.signin is not a function


目标

  1. 我正在尝试在我的自定义元素中实施用户身份验证。
  2. 我正在使用 Google 的身份验证服务来处理身份验证。
  3. 出于样式目的,我使用自己的自定义 <paper-button> 而不是 <google-signin> 元素附带的按钮。
  4. 我正在使用 <google-signin-aware> 元素进行身份验证。 Here is the documentation. Here is the Github.

假设

  1. 我无法更改 <google-signin> 元素附带的显示按钮的样式来充分满足我的 UX 设计 objective。
  2. 因此,我必须使用<google-signin-aware>非显示元素来处理用户认证任务。
  3. <google-signin-aware> 以这种方式使用时能够处理身份验证任务。即,独立于 <google-signin> 元素。

代码

<dom-module id="my-auth">
  <template>
    <google-signin-aware id="authgoogle"></google-signin-aware>
    <paper-button on-tap="_handleAuth">Login with Google</paper-button>
  </template>
</dom-module>
<script>
  (function() {
    Polymer({
      is: 'my-auth',
      _handleAuth: function(e) {
        this.$.authgoogle.signin();
      }
    });
  })();
</script>

正确的函数调用语法是.signIn()

首先,我使用了.login()。然后我使用 .signin() (没有驼峰)。

一个警示故事:第二双眼睛总是很方便。