Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/461.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用内容宽度设置textarea?_Javascript_Css_Reactjs_Textarea_Semantic Ui - Fatal编程技术网

Javascript 如何使用内容宽度设置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)} /

我正在使用react语义ui textarea,我想根据其内容设置宽度。最小宽度没有帮助。有什么想法吗

<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)。语义用户界面没有任何现成的解决方案。