问题
Question
What could be causing the following console error?
Uncaught TypeError: this.$.authgoogle.signin is not a function
Goals
- I am trying to implement a user authentication in my custom element.
- I am using Google's authentication services to handle the authentication.
- For styling purposes, I am using my own custom
<paper-button>
instead of the button that comes with, say, the<google-signin>
element. - I am using the
<google-signin-aware>
element to do the authentication. Here is the documentation. Here is the Github.
Assumptions
- I can not change the styling of the display button that comes with the
<google-signin>
element to sufficiently meet my UX design objective. - Therefore, I must use the
<google-signin-aware>
non-display element to handle the user authentication task. - 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