首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >React Google Login内联样式

React Google Login内联样式
EN

Stack Overflow用户
提问于 2019-03-06 20:24:40
回答 2查看 6.2K关注 0票数 3

我使用的是google-login包。我已经尝试更新按钮的背景图像和尺寸,它似乎不起作用,或者我做错了?我在文档中找不到任何关于如何实现内联样式的示例。我刚读到它是一个对象,下面是我的代码。

代码语言:javascript
复制
 <GoogleLogin
    className="rounded-circle"
    icon={false}
    clientId={process.env.REACT_APP_CLIENT_ID}
    buttonText=""
    onSuccess={this.responseGoogle}
    onFailure={this.responseGoogle}
    style={{  backgroundImage:url(${val.image.url}),
       width:50,
       height:50  
   }}
 />

Plugin在这方面的任何帮助都会很有帮助。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-03-06 21:00:33

这似乎是不可能的,你可以使用自定义的渲染方法。

代码语言:javascript
复制
 <GoogleLogin
    clientId="658977310896-knrl3gka66fldh83dao2rhgbblmd4un9.apps.googleusercontent.com"
    render={renderProps => (
      <button onClick={renderProps.onClick} style={customStyle}>This is my custom Google button</button>
    )}
    buttonText="Login"
    onSuccess={responseGoogle}
    onFailure={responseGoogle}
/>

你可以检查here,css规则来自外部css文件是ignored.You可以读取它的herehere

或者,您可以使用其他插件:react-google-button

票数 12
EN

Stack Overflow用户

发布于 2021-02-27 06:39:42

实际上,您可以将react-google-loginreact-google-button结合使用:

代码语言:javascript
复制
import ReactDOM from 'react-dom';
import GoogleLogin from 'react-google-login';
import GoogleButton from 'react-google-button'

ReactDOM.render(
  <GoogleLogin
    clientId="your-google-app-client-id.apps.googleusercontent.com"
    render={renderProps => (
      <GoogleButton onClick={renderProps.onClick} disabled={renderProps.disabled}>Sign in with Google</GoogleButton>
    )}
    onSuccess={responseGoogleSuccess}
    onFailure={responseGoogleFailure}
    cookiePolicy={'single_host_origin'}
  />,
  document.getElementById('googleButton')
);
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55023073

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档