小编Cro*_*row的帖子

给定的客户端 ID (GSI) 不允许使用给定的来源

我正在重构我的“使用 Google 登录”,将其替换gapigsion http://localhost:8080

声称如何才能gapi毫无问题地工作。gsiThe given origin is not allowed for the given client ID

在此输入图像描述

加皮

<script src="https://apis.google.com/js/api:client.js" async defer></script>
Run Code Online (Sandbox Code Playgroud)
<script src="https://apis.google.com/js/api:client.js" async defer></script>
Run Code Online (Sandbox Code Playgroud)

通用汽车公司

<script src="https://accounts.google.com/gsi/client" async defer></script>
Run Code Online (Sandbox Code Playgroud)
window.gapi.load('auth2', () => {
  const auth2 = window.gapi.auth2.init({ client_id })
  auth2.signIn().then(console.log)
})
Run Code Online (Sandbox Code Playgroud)

错误如下:The given origin is not allowed for the given client ID

javascript google-signin

130
推荐指数
6
解决办法
10万
查看次数

如何通过上下文设置“使用 Google 登录 (GSI)”按钮的响应宽度

我从https://developers.google.com/identity/gsi/web/guides/personalized-button添加了“使用 Google 登录”按钮

默认样式填充整个宽度并且看起来不错: 在此输入图像描述

但如果您有帐户,它会在上下文中显示它: 在此输入图像描述

此上下文添加width到 iframe 内部的元素样式。我知道按照规范 Google 按钮应该在 40-400px 范围内。我想制作页面容器max-width: 400px,但这个按钮根本无法与容器一起缩放。

我是否必须使用 JavaScript 来更新data-width属性,或者是否有 CSS 的正常解决方案?

  <div class="g_id_signin" data-width="400" />
Run Code Online (Sandbox Code Playgroud)

css google-signin

12
推荐指数
1
解决办法
5099
查看次数

TypeScript 中的 .valueOf() 和 .toString()

在 TypeScript 中是否有“正确”的使用.valueOf()and方法.toString()

export default class Measure extends Number implements Number {
  public symbol = ''
  constructor(value: number | string | Measure, symbol?: string) {
    super(value)
    if (symbol) {
      this.symbol = symbol
    }
  }

  public valueOf = (): number => {
    return parseFloat(this.toPrecision(12))
  }

  public toString = (): string => {
    return String(this.valueOf()) + this.symbol
  }
}
Run Code Online (Sandbox Code Playgroud)

.valueOf()

  • Number() 有效;
  • +作品;
  • 在数字环境中工作;
  • ts-lint 抱怨;

.toString()

  • String() 有效;
  • 在字符串上下文中不起作用;
  • ts-lint 不会抱怨;

测试

import Measure from '../src/testing'

describe('Measure …
Run Code Online (Sandbox Code Playgroud)

typescript

7
推荐指数
0
解决办法
893
查看次数

标签 统计

google-signin ×2

css ×1

javascript ×1

typescript ×1