简体   繁体   English

Apple 登录按钮不能在 web 页面中出现两次

[英]Apple login button cant appear twice in a web page

I am trying to put two login buttons in a same page this is because i have two users a student and a tutor.我试图在同一页面中放置两个登录按钮,这是因为我有两个用户,一个是学生,一个是导师。 When there is only one button it is working fine but when i put another button on the same page i am getting error (Unhandled Rejection (ReferenceError): AppleID is not defined).当只有一个按钮时它工作正常但是当我在同一页面上放置另一个按钮时我收到错误消息(未处理的拒绝(ReferenceError):AppleID 未定义)。 Can anyone pls help me is there any way to have the apple login button twice on the same page?任何人都可以帮助我有什么办法可以在同一页面上两次使用苹果登录按钮吗? i am implemeting using reactjs and bootstrap.我正在使用 reactjs 和引导程序来实现。

I created two different client id for those two buttons.我为这两个按钮创建了两个不同的客户端 ID。 But i dont know whats the problem is但我不知道问题出在哪里

I have two div tags in my webpage one is for the user我的网页中有两个 div 标签,一个是给用户的

This is for student.这是给学生的。 and the url is- https://test.example.com/sign-up而 url 是 - https://test.example.com/sign-up

<div className="col-12 col-sm-12 mt-2">
 <AppleLogin
 clientId={globalVariable.APPLE_ID}                                                  
 redirectURI="https://test.example.com/sign-up"
 usePopup={true}
 callback={(e) => this.getAppleToken(e, 'student')}
 scope="email name"
 responseMode="query"
 render={renderProps => (
 <div className='btn btn-google'                              
  onClick={renderProps.onClick}                                                          
  disabled={renderProps.disabled}                                                        
 >                                                               
  Continue with Apple
</div>
)}
/>
</div>

i have another button for tutor and the url for tutor also same https://test.example.com/sign-up我有另一个导师按钮和 url 导师也一样https://test.example.com/sign-up

<div className="col-12 col-sm-12 mt-2">
 <AppleLogin
 clientId={globalVariable.APPLE_ID}                                                  
 redirectURI="https://test.example.com/sign-up"
 usePopup={true}
 callback={(e) => this.getAppleToken(e, 'tutor')}
 scope="email name"
 responseMode="query"
 render={renderProps => (
 <div className='btn btn-google' 
 onClick={renderProps.onClick}                                                          disabled={renderProps.disabled}                                                     >                                                               Continue with Apple
</div>
)}
/>
</div>

When i have only one button it is working fine But when i have another button the react throws error.当我只有一个按钮时,它工作正常但是当我有另一个按钮时,反应会抛出错误。 ReferenceError: AppleID is not defined ReferenceError: AppleID 未定义

I suggest you to create two buttons instead of rendering buttons from apple library.我建议你创建两个按钮而不是从苹果库中渲染按钮。 And when you load the page do initialize the AppleID with single credentials.当您加载页面时,请使用单一凭据初始化 AppleID。 After that just add a click event to each button to perfrom Window.AppleID.auth.signIn()之后只需向每个按钮添加一个点击事件即可执行 Window.AppleID.auth.signIn()

I am using react js in front end with bootstrap.我在带有引导程序的前端使用 React js。 I faced this when i was trying to implement two apple login buttons on the same page.当我试图在同一页面上实现两个苹果登录按钮时,我遇到了这个问题。 EX- there is a button for a student and another one for the tutor. EX-学生有一个按钮,导师有另一个按钮。 When the second button was implemented i got react error.当第二个按钮被实现时,我得到了反应错误。 The issue here is the package that i installed using the command npm i react-apple-login What seems to be the issue here is that the package attaches the apple id to the id of the div element.这里的问题是我使用命令 npm 安装的 package i react-apple-login 这里的问题似乎是 package 将 apple id 附加到 div 元素的 id。 So inorder to resolve this we have to pass an id with the button so that we can use them twice on a single page.所以为了解决这个问题,我们必须通过按钮传递一个 id,这样我们就可以在一个页面上使用它们两次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM