reactjs - React Google 登录内联样式
问题描述
我正在使用 google-login 包。我试图更新按钮的背景图像和尺寸,它似乎不起作用或者我做错了吗?我在文档中找不到任何关于如何实现内联样式的示例。我刚刚读到它是一个对象,这是我的代码。
<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
}}
/>
插件对此的任何帮助都会有所帮助。
解决方案
似乎不可能,您可以使用自定义渲染方法。
<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}
/>
您可以在此处查看,来自外部 css 文件的 css 规则将被忽略。您可以在此处和此处阅读
或者您可以使用替代插件:react-google-button
推荐阅读
- powershell - 使用 Powershell 检查 RDP 登录成功
- powershell - 在 applicationHost.config 上替换 Powershell 导致格式不正确的 xml 错误
- c# - IsValidExpiration 方法的当前上下文中不存在 txt_ExpirationDate
- spring - 春天的依赖对象
- php - 重新格式化字符串 PHP 数组中的数字
- node.js - 使用带有 mongodb `connect` 的数据库
- php - 触发按钮单击 Enter
- hyperledger-fabric - Hyperledger Fabric:无法将所有对等方加入通道。原因:TypeError:client.getEventHubsForOrg 不是函数
- tfs - 在进行 TFS 部署时配置多个主机头名称
- reactjs - React.js 中的状态不会立即更新