我有一个情况,需要给 div
动态设置宽度,所以我需要在我的 React Js 代码中使用这个 divStyle = {width: calc(100% - 276px)}
。但是这样做会出现错误提示 calc is not a function
。
我知道可以使用 JQuery 来实现这个目的,但我不想在我的应用程序中引入 JQuery。如果有任何解决方法或技巧,请分享。
代码:
customFormat = 'hello-div'
divStyle = {width: calc(100% - 276px)}
return (
<div className={customFormat} style={divStyle}>
Hello World
</div>
)
divStyle = '{width: calc(100% - 276px)}'
- Roysh