我的功能addthisTxt
未檢查長度。它不應該超過11.以下是我迄今爲止所嘗試的;我想繼續添加文字,直到達到最大長度,否則應限制用戶添加更多內容。限制輸入中的字符/字符串/字
HTML
<input type="checkbox" name="chkbxr" value="add this offer on wrapper"
(change)="addthisTxt($event.target.getAttribute('txt'), $event.target.checked)">
的JavaScript
addthisTxt(txt, checked): void {
if (checked) {
if((this.v.offerName.length +txt.length) >= 55){
this.v.offerName = this.v.offerName + txt;
}
this.v.offerName = this.v.offerName;
}
}
什麼是this.v.offername? –
@ R.Anandan this.v.offername具有來自db的數據。然後我用它添加動態文本從UI和請檢查更新代碼 –