【发布时间】:2021-12-26 17:46:29
【问题描述】:
我正在尝试为 React 中的道具赋予样式,但我不知道正确的编写方式:
<PhoneInput
inputStyle={!(window.innerWidth <= 768) ? {...InputDivStyle, ...PhoneInputStyle, textIndent: "96px"} : {...InputDivStyle, ...PhoneInputStyle, textIndent: "32px"}}
</PhoneInput>
inputStyle 给了我错误:
Types of property 'boxSizing' are incompatible. Type 'string' is not assignable to type 'BoxSizing | undefined'.ts(2322)
export const PhoneInputStyle = {
fontSize: "clamp(13px, 1.111vw, 16px)",
lineHeight: "clamp(15px, 1.319vw, 19px)",
position: "relative",
width: "100%",
height: "51px",
cursor: "pointer",
display: "flex",
flexDirection: "row",
alignItems: "center",
padding: "8px 16px",
border: `1px solid black`,
boxSizing: `border-box`, //This ain't right, I tried "border-box" and it didn't work either
borderRadius: "10px",
outline: "none",
gridRowStart: "1",
gridColumnStart: "1",
}
我很确定这只是语法错误,但我找不到正确的 boxSizing 方法。
【问题讨论】:
-
这是我的问题,我不知道怎么写,因为写
boxSizing: border-box或boxSizing: borderBox给了我Cannot find name 'border-box' -
@Terry,BoxSizing 不是枚举。问题是关于一般字符串与特定字符串
标签: javascript html css reactjs typescript