文字数を取得しようとしていますが、それに基づいてフォントの色を変更したいと考えています。
私は試してみましqueryselector()
たが、うまくいきません:
handleChange(event) {
if( this.charCount > 100){
let textcolor = this.template.queryselector("lightning-input-rich-text");
textcolor.getformat({color:"red"});
}
}
私も試しました:
handleChange(event) {
if( this.charCount > 100){
textcolor = this.template.queryselector('[data-id="summary"]');
if(textcolor)
this.template.querySelector('[data-
id="summarytextcolor"]').className='summarytext';
}
}
ここに私のCSSがあります:
.summarytext {color: #ff0000;}
そして、これが私の稲妻コードです。ここでは、変更時に文字数を取得する必要があるリッチテキストフィールドを取得しています。
<lightning-input-rich-text
data-id="summary"
label={label.Summary}
formats={richTextformats}
label-visible
valid={richTextValidity}
message-when-bad-input={richTextErrorMessage}
class="slds-form-element slds-form-element_stacked summarytext"
onchange={handleChange}
value={richTextValue}
style=" font-weight: normal;">
</lightning-input-rich-text>
ここに私が得ているエラーがあります:
[NoErrorObjectAvailable] Script error. a()@https://static.lightning.force.com/cs10/auraFW/javascript/7p9HLMpgnV2GO9MqZhXGUw/aura_prod.js:948:169 {anonymous}()@https://static.lightning.force.com/cs10/auraFW/javascript/7p9HLMpgnV2GO9MqZhXGUw/aura_prod.js:948:362 bt.dispatchEvent()@https://static.lightning.force.com/cs10/auraFW/javascript/7p9HLMpgnV2GO9MqZhXGUw/aura_prod.js:12:12146 bt.dispatchChangeEvent()@https://customization-velocity-2311-dev-ed.lightning.force.com/components/interop/inputRichText.js:2:28144 eval()@https://customization-velocity-2311-dev-ed.lightning.force.com/components/interop/inputRichText.js:2:20578 e.l.emit()@https://customization-velocity-2311-dev-ed.lightning.force.com/components/lightning/quillLib.js:2:142032 e.value()@https://customization-velocity-2311-dev-ed.lightning.force.com/components/lightning/quillLib.js:2:33139
何が問題で、どうすれば修正できますか?