【发布时间】:2021-06-06 08:05:35
【问题描述】:
我正在尝试动态更改我的反应应用程序的标题部分。 我想要我的 React Web 应用程序的主页和其他页面使用不同的字体大小、字体粗细、标题和副标题。 这就是我想要的主页。 Hello there 在首页上应该较小,但 Welcome Back 应该较大
这是我在其他页面上想要的。 Hello there 在主页上应该更大,但 lorem ipsum lorem ipsum 应该很小
这是我的主页标题代码
const Hero = ({ fontSize, fontWeight, title, subTitle }) => {
return (
<div className="mt-2 mb-8">
<p className="font-heading text-lg font-normal text-white">Hello There ????,</p>
<p className="font-heading text-3xl font-bold text-white">{subTitle}</p>
// another react component
</div>
)
}
export default Hero
我想知道如何动态更改此代码,以便我可以将它用于其他页面,绕过字体粗细、字体大小、标题和副标题的不同属性。 我正在使用 react 和 tailwind css
任何人请帮我解决这个问题。 谢谢 已编辑:
{pathName === '/' ? (
<>
<p className="font-heading text-lg font-normal text-white">`Hello There ????,</p>
<p className="font-heading text-3xl font-semibold text-white">{subTitle}</p>
</>
) : (
<>
<p className="font-heading text-3xl font-semibold text-white">Hello There ????,</p>
<p className="font-heading text-lg font-normal text-white">subTitle</p>
</>
)}
【问题讨论】:
标签: css reactjs jsx tailwind-css