如何使用React Cookie同意库的按钮组件



有人能就如何使用react cookie同意库的ButtonComponent提出建议吗。我想在接受和拒绝按钮的顶部添加第三个按钮。查看他们的文档,有一个按钮组件,其描述如下:ButtonComponent|React component|button|React component渲染为按钮。

我尝试以不同的方式使用它,作为CookieConsent组件<ButtonComponent/>的组件子级,或作为道具`

<CookieConsent ButtonComponent="button"
ButtonComponentStyle={
color: "#ffff",
background: "#245564",
padding: "10px 20px",
borderRadius: "16px",
fontSize: "1em",
display: "flex",
alignContent: "center",
}>
</CookieConsent>

这些都不起作用。

也许为时已晚,但我认为解决方案是添加"enableDeclineButton";以及";declineButtonText=";拒绝";。像这样:

<CookieConsent
location="bottom"
buttonText="Accept"
cookieName="cookieName"
enableDeclineButton
declineButtonText="Decline"
declineCookieValue={false}
style={{ background: "#2EB7EB" }}
buttonStyle={{ background:"#f5f5f5", color: "black", fontSize:"13px"}}
declineButtonStyle={{background:"#cfcfcf", color: "black", fontSize: "13px"}}
expires={150}> 
</CookieConsent>

最新更新