动态调整Lightning-Input-Rich-Text的文本区域
用户在文本区域内创建多个换行符后,我尝试增加文本区域框的高度。我在寻找一种方法来定位文本区域高度的值以增加每个换行符的值时遇到问题。我将不胜感激任何帮助。谢谢。
import { LightningElement } from 'lwc';
export default class TextBoxSizing extends LightningElement {
handleTextBoxChange(event){
let eventArr = [];
let lineBreaks = 0;
eventArr.push(...event.target.value);
eventArr.forEach(e =>{
if(e == '/'){
lineBreaks++;
if(lineBreaks > 5) {
let lirt = this.template.querySelector('lightning-input-rich-text').height; //undefined
console.log(lirt);
}
}
});
}
}
Im trying to increase the height of the textarea box after a user creates several line breaks within the textarea. I'm having issues finding a way to target the value of the textarea height in order to increase it per line break. I would appreciate any help. Thank you.
import { LightningElement } from 'lwc';
export default class TextBoxSizing extends LightningElement {
handleTextBoxChange(event){
let eventArr = [];
let lineBreaks = 0;
eventArr.push(...event.target.value);
eventArr.forEach(e =>{
if(e == '/'){
lineBreaks++;
if(lineBreaks > 5) {
let lirt = this.template.querySelector('lightning-input-rich-text').height; //undefined
console.log(lirt);
}
}
});
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您见过样式挂钩吗?阅读文章,阅读 textarea 的文档,检查是否添加
TextBoxSizing.css
与类似的东西可以正常工作。
如果确实如此,下一步就是向 CSS 添加一个 JavaScript 控制的变量。我不久前也有类似的问题:https://salesforce.stackexchange.com/q/341324/799
像这样?
Have you seen styling hooks? Read the article, read the documentation for textarea, check if adding
TextBoxSizing.css
with something likeworks OK.
If it does - next step would be to add a JavaScript-controlled variable to CSS. I had similar question a while ago: https://salesforce.stackexchange.com/q/341324/799
Something like this?
如果有人需要它,我选择了以下
100% 富文本区域
In case someone needs it, I went for the following
100% Rich Text Area