Javascript 如何使用内容宽度设置textarea?
我正在使用react语义ui textarea,我想根据其内容设置宽度。最小宽度没有帮助。有什么想法吗Javascript 如何使用内容宽度设置textarea?,javascript,css,reactjs,textarea,semantic-ui,Javascript,Css,Reactjs,Textarea,Semantic Ui,我正在使用react语义ui textarea,我想根据其内容设置宽度。最小宽度没有帮助。有什么想法吗 <Textarea key={idx} defaultValue={formattedText} className="customInput" maxLength="100" name={idx} onChange={e => this.handleChange(e)} /
<Textarea
key={idx}
defaultValue={formattedText}
className="customInput"
maxLength="100"
name={idx}
onChange={e => this.handleChange(e)}
/>
this.handleChange(e)}
/>
您可以在vue中绑定样式属性,如下所示
<Textarea :style="widthContent"/>
export default {
computed:{
widthContent(){
//caculate your width here
return {width: ...px}
}
}
}
导出默认值{
计算:{
宽度内容(){
//在这里计算你的宽度
返回{宽度:…px}
}
}
}
更多详情:
您可以在vue中绑定style attr,如下所示
<Textarea :style="widthContent"/>
export default {
computed:{
widthContent(){
//caculate your width here
return {width: ...px}
}
}
}
导出默认值{
计算:{
宽度内容(){
//在这里计算你的宽度
返回{宽度:…px}
}
}
}
更多详情:
我认为您需要编写一个函数(onChange=>计算宽度)。语义用户界面没有任何现成的解决方案。我认为您需要编写一个函数(onChange=>calculatewidth)。语义用户界面没有任何现成的解决方案。