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

你。 提交于 2019-12-13 04:58:51

问题


Question

What could be causing the following console error?

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


Goals

  1. I am trying to implement a user authentication in my custom element.
  2. I am using Google's authentication services to handle the authentication.
  3. For styling purposes, I am using my own custom <paper-button> instead of the button that comes with, say, the <google-signin> element.
  4. I am using the <google-signin-aware> element to do the authentication. Here is the documentation. Here is the Github.

Assumptions

  1. I can not change the styling of the display button that comes with the <google-signin> element to sufficiently meet my UX design objective.
  2. Therefore, I must use the <google-signin-aware> non-display element to handle the user authentication task.
  3. The <google-signin-aware> is capable of handling the authentication task when used this way. I.e., independently of the <google-signin> element.

Code

<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>

回答1:


The correct function call syntax is .signIn().

First, I used .login(). Then I used .signin() (without the camelCase).

A cautionary tale: A second pair of eyes is always handy.



来源:https://stackoverflow.com/questions/31632661/polymer-1-0-what-could-be-causing-this-error-uncaught-typeerror-this-is-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!