聚合物1.0:什么可能导致此错误? “未捕获的TypeError:这不是函数" [英] Polymer 1.0: What could be causing this error? "Uncaught TypeError: this is not a function"

查看:81
本文介绍了聚合物1.0:什么可能导致此错误? “未捕获的TypeError:这不是函数"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么可能导致以下控制台错误?

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


目标

  1. 我正在尝试在我的自定义元素中实现用户身份验证.
  2. 我正在使用Google的身份验证服务来处理身份验证.
  3. 出于样式目的,我使用了自己的自定义<paper-button>而不是<google-signin>元素附带的按钮.
  4. 我正在使用<google-signin-aware>元素进行身份验证. 此处是文档. 这里是Github .
  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.


假设

  1. 我无法更改<google-signin>元素随附的显示按钮的样式,以完全满足我的UX设计目标.
  2. 因此,我必须使用<google-signin-aware>非显示元素来处理用户身份验证任务.
  3. <google-signin-aware>以这种方式使用时能够处理身份验证任务.即独立于<google-signin>元素.
  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.


代码

<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().

The correct function call syntax is .signIn().

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

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

一个警告性的故事:第二双眼睛总是很方便.

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

这篇关于聚合物1.0:什么可能导致此错误? “未捕获的TypeError:这不是函数"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆