这个问题通常是由于使用了过时的Google API导致的。解决方法是使用最新的Google API,特别是将gapi库的版本升级到最新版本。
要使用最新版本的gapi库,请将以下代码添加到index.html文件中:
然后,在login.component.ts文件中的代码中,将gapi的版本从旧版本升级到最新版本:
const gapiAuth = gapi.auth2.init({
client_id: 'yourClientId.apps.googleusercontent.com',
cookiepolicy: 'single_host_origin',
scope: 'profile email'
});
gapiAuth.signIn().then((response) => {
// handle sign in successful response here
}, (error) => {
// handle sign in error here
});
如果您的代码中仍然存在问题,请检查是否存在任何其他使用了较旧版本的Google API的地方,并将它们升级到最新版本。